使用PUT端点时创建的重复客户 - Square Connect

时间:2018-01-30 20:01:56

标签: python square

我创建了一个帮助函数来更新类中的客户数据。当我调用该函数时,它会更新所有信息。如果我在我的测试中再次尝试它...它会在客户数据库中创建一个新条目,创建一个副本..

我无法弄清楚它是我的逻辑还是我做错了什么。有人可以帮忙。

我正在使用HTTP请求包

发起课程

self.customer = Sq_Customer(
            first_name = 'Testy',
            last_name = 'McTesty',
            email = 'McTesty@testy.com',
            phone= '123-456-7890'
            )

更新用户JSON和函数调用

    self.data = {
                'given_name': 'Dummy',
                'email_address': dummy_account@testing.com',
                'address': {
                    'address_line_1': '1234 Main Street',
                    'address_line_2': '',
                    'locality': 'New York',
                    'administrative_district_level_1': 'NY',
                    'postal_code': '11413',
                    'country': 'US'
                }
            }


 self.update_customer = self.customer.update_customer_acct(Customer ID, self.data)

我的助手功能

def update_customer_acct(self, user_id, data):
        '''
        Update Customer information.
        '''
        self.customer = self.get_customer(user_id)
        if self.customer['customer']['id'] == user_id:
            self.update_customer_data = self.connect.put('/v2/customers/' + user_id, data)
            return self.__sqware_json_decoder(self.update_customer_data)
        else:
            return '{}'.format('There is no account associated with that ID.')

1 个答案:

答案 0 :(得分:0)

我删除了电子邮件,不再重复了。这是我在测试期间创建客户的问题。更改电子邮件后,它会创建一个新帐户。再次感谢。