-
Notifications
You must be signed in to change notification settings - Fork 52
/
test_customer.rb
54 lines (46 loc) · 1.51 KB
/
test_customer.rb
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
42
43
44
45
46
47
48
49
50
51
52
53
54
# typed: true
# frozen_string_literal: true
require_relative '../lib/mercadopago'
require 'minitest/autorun'
class TestCustomer < Minitest::Test
def test_all
sdk = Mercadopago::SDK.new('TEST-783169576377080-082620-395ee7f82e0d55b1db606c118686c1db-464842924')
customer_object = {
email: '[email protected]',
first_name: 'Rafa',
last_name: 'Williner',
phone: {
area_code: '03492',
number: '432334'
},
identification: {
type: 'DNI',
number: '29804555'
},
address: {
zip_code: '2300',
street_name: 'some street'
},
description: 'customer description'
}
begin
customer_saved = sdk.customer.create(customer_object)
assert_equal 201, customer_saved[:status]
sleep(1)
customers = sdk.customer.search(filters: { email: '[email protected]' })
assert_equal 200, customers[:status]
sleep(1)
customer_update = sdk.customer.update(customer_saved[:response]['id'], { last_name: 'Payer' })
assert_equal 200, customer_update[:status]
sleep(1)
customer_updated = sdk.customer.get(customer_saved[:response]['id'])
assert_equal 'Payer', customer_updated[:response]['last_name']
sleep(1)
ensure
if customer_saved.key?(:response) && customer_saved[:response].key?('id')
customer_deleted = sdk.customer.delete(customer_saved[:response]['id'])
assert_equal 200, customer_deleted[:status]
end
end
end
end