forked from square/square-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_customers_api.py
More file actions
41 lines (35 loc) · 1.51 KB
/
test_customers_api.py
File metadata and controls
41 lines (35 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
from tests.api.api_test_base import ApiTestBase
from square.api_helper import APIHelper
class CustomersApiTests(ApiTestBase):
@classmethod
def setUpClass(cls):
super(CustomersApiTests, cls).setUpClass()
cls.controller = cls.client.customers
cls.response_catcher = cls.controller.http_call_back
# Creates a new customer for a business, which can have associated cards on file.
#
#You must provide __at least one__ of the following values in your request to this
#endpoint:
#
#- `given_name`
#- `family_name`
#- `company_name`
#- `email_address`
#- `phone_number`
#
#This endpoint does not accept an idempotency key. If you accidentally create
#a duplicate customer, you can delete it with the
#[DeleteCustomer](#endpoint-deletecustomer) endpoint.
def test_create_customer(self):
# Parameters for the API call
body = APIHelper.json_deserialize(
'{"given_name":"Amelia","family_name":"Earhart","email_address":"Amelia.Ear'
'hart@example.com","address":{"address_line_1":"500 Electric Ave","address_l'
'ine_2":"Suite 600","locality":"New York"},"phone_number":"1-212-555-4240","'
'reference_id":"YOUR_REFERENCE_ID","note":"a customer"}'
)
# Perform the API call through the SDK function
result = self.controller.create_customer(body)
# Test response code
self.assertEquals(self.response_catcher.response.status_code, 200)