moip2 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +644 -0
- data/.travis.yml +14 -3
- data/CONTRIBUTING.md +42 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +25 -6
- data/Guardfile +1 -2
- data/README.md +373 -74
- data/Rakefile +2 -2
- data/changelog.md +36 -0
- data/lib/moip2/accounts_api.rb +27 -0
- data/lib/moip2/api.rb +25 -2
- data/lib/moip2/auth/basic.rb +2 -5
- data/lib/moip2/auth/oauth.rb +0 -3
- data/lib/moip2/client.rb +45 -31
- data/lib/moip2/connect_api.rb +41 -0
- data/lib/moip2/customer_api.rb +16 -2
- data/lib/moip2/exceptions/invalid_enviroment_error.rb +0 -2
- data/lib/moip2/invoice_api.rb +8 -3
- data/lib/moip2/keys_api.rb +14 -14
- data/lib/moip2/multi_order_api.rb +1 -3
- data/lib/moip2/multi_payment_api.rb +1 -1
- data/lib/moip2/notifications_api.rb +33 -0
- data/lib/moip2/order_api.rb +18 -3
- data/lib/moip2/payment_api.rb +11 -1
- data/lib/moip2/refund_api.rb +5 -4
- data/lib/moip2/resource/account.rb +12 -0
- data/lib/moip2/resource/connect.rb +9 -0
- data/lib/moip2/resource/credit_card.rb +12 -0
- data/lib/moip2/resource/customer.rb +0 -4
- data/lib/moip2/resource/invoice.rb +0 -2
- data/lib/moip2/resource/keys.rb +1 -3
- data/lib/moip2/resource/multi_order.rb +2 -6
- data/lib/moip2/resource/multi_payment.rb +1 -3
- data/lib/moip2/resource/notification.rb +12 -0
- data/lib/moip2/resource/order.rb +0 -4
- data/lib/moip2/resource/payment.rb +0 -4
- data/lib/moip2/resource/refund.rb +1 -2
- data/lib/moip2/resource/webhooks.rb +11 -13
- data/lib/moip2/response.rb +7 -7
- data/lib/moip2/util/filters_encoder.rb +28 -0
- data/lib/moip2/version.rb +1 -1
- data/lib/moip2/webhooks_api.rb +16 -16
- data/lib/moip2.rb +10 -5
- data/moip2.gemspec +21 -7
- data/spec/moip2/accounts_api_spec.rb +189 -0
- data/spec/moip2/api_spec.rb +22 -4
- data/spec/moip2/auth/basic_spec.rb +8 -4
- data/spec/moip2/auth/oauth_spec.rb +4 -4
- data/spec/moip2/client_spec.rb +20 -27
- data/spec/moip2/connect_api_spec.rb +68 -0
- data/spec/moip2/customer_api_spec.rb +147 -72
- data/spec/moip2/invoice_spec.rb +51 -32
- data/spec/moip2/keys_spec.rb +16 -18
- data/spec/moip2/multi_order_api_spec.rb +99 -108
- data/spec/moip2/multi_payment_api_spec.rb +8 -11
- data/spec/moip2/notifications_api_spec.rb +104 -0
- data/spec/moip2/order_api_spec.rb +100 -20
- data/spec/moip2/payment_api_spec.rb +77 -17
- data/spec/moip2/refund_api_spec.rb +2 -4
- data/spec/moip2/resource/order_spec.rb +24 -28
- data/spec/moip2/response_spec.rb +0 -8
- data/spec/moip2/webhooks_spec.rb +18 -21
- data/spec/moip2_spec.rb +6 -13
- data/spec/spec_helper.rb +24 -10
- data/vcr_cassettes/_create_invoice.yml +42 -0
- data/vcr_cassettes/_get_invoice.yml +41 -0
- data/vcr_cassettes/account_doesnt_exist.yml +44 -0
- data/vcr_cassettes/account_exists.yml +46 -0
- data/vcr_cassettes/accounts_show_existent.yml +50 -0
- data/vcr_cassettes/accounts_show_nonexistent.yml +42 -0
- data/vcr_cassettes/cancel_payment.yml +43 -0
- data/vcr_cassettes/capture_payment.yml +42 -0
- data/vcr_cassettes/create_account_success_company.yml +87 -0
- data/vcr_cassettes/create_account_success_standalone.yml +74 -0
- data/vcr_cassettes/create_credit_card_customer.yml +41 -0
- data/vcr_cassettes/create_invoice.yml +10 -16
- data/vcr_cassettes/create_notification.yml +38 -0
- data/vcr_cassettes/create_notification_app.yml +38 -0
- data/vcr_cassettes/delete_credit_card_customer.yml +40 -0
- data/vcr_cassettes/delete_nonexistent_credit_card_customer.yml +40 -0
- data/vcr_cassettes/delete_nonexistent_notification.yml +40 -0
- data/vcr_cassettes/delete_notification.yml +36 -0
- data/vcr_cassettes/find_all_orders_filters.yml +56 -0
- data/vcr_cassettes/find_all_orders_limit.yml +48 -0
- data/vcr_cassettes/find_all_orders_multi_filters.yml +57 -0
- data/vcr_cassettes/find_all_orders_no_filter.yml +56 -0
- data/vcr_cassettes/generate_oauth_token.yml +42 -0
- data/vcr_cassettes/get_invoice.yml +10 -15
- data/vcr_cassettes/get_keys.yml +1 -1
- data/vcr_cassettes/get_notification.yml +38 -0
- data/vcr_cassettes/get_notifications_list.yml +38 -0
- data/vcr_cassettes/get_payment.yml +42 -0
- data/vcr_cassettes/get_payment_not_found.yml +40 -0
- data/vcr_cassettes/get_webhooks.yml +1 -1
- data/vcr_cassettes/list_invoices.yml +2 -2
- data/vcr_cassettes/refresh_oauth_token.yml +40 -0
- data/vcr_cassettes/update_invoice.yml +1 -1
- metadata +69 -7
@@ -0,0 +1,68 @@
|
|
1
|
+
describe Moip2::ConnectApi do
|
2
|
+
let(:connect_api) { described_class.new sandbox_client_connect }
|
3
|
+
|
4
|
+
describe "#authorize_url" do
|
5
|
+
let (:authorize_url) do
|
6
|
+
connect_api.authorize_url(
|
7
|
+
"APP-XT5FIAK2F8I7",
|
8
|
+
"http://localhost/moip/callback.php",
|
9
|
+
"RECEIVE_FUNDS,REFUND,MANAGE_ACCOUNT_INFO,RETRIEVE_FINANCIAL_INFO,TRANSFER_FUNDS",
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "get authorize url" do
|
14
|
+
expect(authorize_url).to eq(
|
15
|
+
"https://connect-sandbox.moip.com.br/oauth/authorize"\
|
16
|
+
"?response_type=code&client_id=APP-XT5FIAK2F8I7"\
|
17
|
+
"&redirect_uri=http%3A%2F%2Flocalhost%2Fmoip%2Fcallback.php"\
|
18
|
+
"&scope=RECEIVE_FUNDS%2CREFUND%2CMANAGE_ACCOUNT_INFO%2C"\
|
19
|
+
"RETRIEVE_FINANCIAL_INFO%2CTRANSFER_FUNDS",
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#generate_oauth_token" do
|
25
|
+
let (:oauth_token) do
|
26
|
+
VCR.use_cassette("generate_oauth_token") do
|
27
|
+
connect_api.authorize(
|
28
|
+
client_id: "APP-Y0YCCJ5P603B",
|
29
|
+
client_secret: "363cdf8ab70a4c5aa08017564c08efbe",
|
30
|
+
code: "4efde1f89d9acc3b12124ccfded146518465e423",
|
31
|
+
redirect_uri: "http://localhost/moip/callback.php",
|
32
|
+
grant_type: "authorization_code",
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "token generated" do
|
38
|
+
expect(oauth_token.refresh_token).to_not be_nil
|
39
|
+
expect(oauth_token.scope).to eq(
|
40
|
+
"DEFINE_PREFERENCES,MANAGE_ACCOUNT_INFO,RECEIVE_FUNDS,"\
|
41
|
+
"REFUND,RETRIEVE_FINANCIAL_INFO,TRANSFER_FUNDS",
|
42
|
+
)
|
43
|
+
expect(oauth_token.access_token).to end_with "_v2"
|
44
|
+
expect(oauth_token.expires_in).to eq "2027-09-15"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#refresh_oauth_token" do
|
49
|
+
let (:oauth_token_refresh) do
|
50
|
+
VCR.use_cassette("refresh_oauth_token") do
|
51
|
+
connect_api.authorize(
|
52
|
+
refresh_token: "f96ee59c608f42c3a4bc0cf560bb4aa8_v2",
|
53
|
+
grant_type: "refresh_token",
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "token refreshed" do
|
59
|
+
expect(oauth_token_refresh.refresh_token).to_not be_nil
|
60
|
+
expect(oauth_token_refresh.scope).to eq(
|
61
|
+
"DEFINE_PREFERENCES,MANAGE_ACCOUNT_INFO,RECEIVE_FUNDS,"\
|
62
|
+
"REFUND,RETRIEVE_FINANCIAL_INFO,TRANSFER_FUNDS",
|
63
|
+
)
|
64
|
+
expect(oauth_token_refresh.access_token).to end_with "_v2"
|
65
|
+
expect(oauth_token_refresh.expires_in).to eq "2027-09-18"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
describe Moip2::CustomerApi do
|
2
|
-
|
3
2
|
let(:customer_api) { described_class.new(sandbox_client) }
|
4
3
|
|
5
4
|
describe "#show" do
|
6
|
-
|
7
5
|
let(:customer_external_id) { "CUS-B6LE6HLFFXKF" }
|
8
6
|
|
9
7
|
let(:customer) do
|
@@ -24,60 +22,61 @@ describe Moip2::CustomerApi do
|
|
24
22
|
it { expect(customer.shipping_address).to_not be_nil }
|
25
23
|
it { expect(customer.shipping_address.zip_code).to eq "01234000" }
|
26
24
|
it { expect(customer._links).to_not be_nil }
|
27
|
-
it {
|
28
|
-
|
25
|
+
it {
|
26
|
+
expect(
|
27
|
+
customer._links.self.href,
|
28
|
+
).to eq "#{ENV['sandbox_url']}/v2/customers/CUS-B6LE6HLFFXKF"
|
29
|
+
}
|
29
30
|
end
|
30
31
|
|
31
32
|
describe "#create with funding instrument" do
|
32
|
-
|
33
33
|
let(:customer_with_funding_instrument) do
|
34
34
|
{
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
ownId: "meu_id_de_cliente",
|
36
|
+
fullname: "Jose Silva",
|
37
|
+
email: "josedasilva@email.com",
|
38
|
+
phone: {
|
39
|
+
areaCode: "11",
|
40
|
+
number: "66778899",
|
41
41
|
},
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
birthDate: "1988-12-30",
|
43
|
+
taxDocument: {
|
44
|
+
type: "CPF",
|
45
|
+
number: "22222222222",
|
46
46
|
},
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
shippingAddress: {
|
48
|
+
street: "Avenida Faria Lima",
|
49
|
+
streetNumber: "2927",
|
50
|
+
complement: "8",
|
51
|
+
district: "Itaim",
|
52
|
+
city: "Sao Paulo",
|
53
|
+
state: "SP",
|
54
|
+
country: "BRA",
|
55
|
+
zipCode: "01234000",
|
56
56
|
},
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
57
|
+
fundingInstrument: {
|
58
|
+
method: "CREDIT_CARD",
|
59
|
+
creditCard: {
|
60
|
+
expirationMonth: 12,
|
61
|
+
expirationYear: 15,
|
62
|
+
number: "4073020000000002",
|
63
|
+
holder: {
|
64
|
+
fullname: "Jose Silva",
|
65
|
+
birthdate: "1988-12-30",
|
66
|
+
taxDocument: {
|
67
|
+
type: "CPF",
|
68
|
+
number: "22222222222",
|
69
69
|
},
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
}
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
70
|
+
phone: {
|
71
|
+
areaCode: "11",
|
72
|
+
number: "66778899",
|
73
|
+
},
|
74
|
+
},
|
75
|
+
},
|
76
|
+
},
|
77
77
|
}
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
80
|
let(:created_customer_with_funding_instrument) do
|
82
81
|
VCR.use_cassette("create_customer_with_funding_instrument") do
|
83
82
|
customer_api.create customer_with_funding_instrument
|
@@ -88,45 +87,59 @@ describe Moip2::CustomerApi do
|
|
88
87
|
it { expect(created_customer_with_funding_instrument.own_id).to eq "meu_id_de_cliente" }
|
89
88
|
it { expect(created_customer_with_funding_instrument.email).to eq "josedasilva@email.com" }
|
90
89
|
it { expect(created_customer_with_funding_instrument.funding_instrument).to_not be_nil }
|
91
|
-
it {
|
92
|
-
|
90
|
+
it {
|
91
|
+
expect(
|
92
|
+
created_customer_with_funding_instrument.funding_instrument.credit_card.id,
|
93
|
+
).to eq "CRC-F5DR8SVINCUI"
|
94
|
+
}
|
95
|
+
it {
|
96
|
+
expect(
|
97
|
+
created_customer_with_funding_instrument.funding_instrument.credit_card.brand,
|
98
|
+
).to eq "VISA"
|
99
|
+
}
|
93
100
|
it { expect(created_customer_with_funding_instrument.phone).to_not be_nil }
|
94
101
|
it { expect(created_customer_with_funding_instrument.tax_document).to_not be_nil }
|
95
102
|
it { expect(created_customer_with_funding_instrument.tax_document.type).to eq "CPF" }
|
96
103
|
it { expect(created_customer_with_funding_instrument.shipping_address).to_not be_nil }
|
97
|
-
it {
|
104
|
+
it {
|
105
|
+
expect(
|
106
|
+
created_customer_with_funding_instrument.shipping_address.zip_code,
|
107
|
+
).to eq "01234000"
|
108
|
+
}
|
98
109
|
it { expect(created_customer_with_funding_instrument._links).to_not be_nil }
|
99
|
-
it {
|
100
|
-
|
110
|
+
it {
|
111
|
+
expect(
|
112
|
+
created_customer_with_funding_instrument._links.self.href,
|
113
|
+
).to eq "#{ENV['sandbox_url']}/v2/customers/CUS-E5CO735TBXTI"
|
114
|
+
}
|
101
115
|
end
|
102
116
|
|
103
117
|
describe "#create without funding instrument" do
|
104
|
-
|
105
118
|
let(:customer) do
|
106
119
|
{
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
120
|
+
ownId: "meu_id_sandbox_1231234",
|
121
|
+
fullname: "Jose Silva",
|
122
|
+
email: "jose_silva0@email.com",
|
123
|
+
birthDate: "1988-12-30",
|
124
|
+
taxDocument: {
|
125
|
+
type: "CPF",
|
126
|
+
number: "22222222222",
|
114
127
|
},
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
128
|
+
phone: {
|
129
|
+
countryCode: "55",
|
130
|
+
areaCode: "11",
|
131
|
+
number: "66778899",
|
132
|
+
},
|
133
|
+
shippingAddress: {
|
134
|
+
city: "Sao Paulo",
|
135
|
+
complement: "8",
|
136
|
+
district: "Itaim",
|
137
|
+
street: "Avenida Faria Lima",
|
138
|
+
streetNumber: "2927",
|
139
|
+
zipCode: "01234000",
|
140
|
+
state: "SP",
|
141
|
+
country: "BRA",
|
119
142
|
},
|
120
|
-
shippingAddress: {
|
121
|
-
city: "Sao Paulo",
|
122
|
-
complement: "8",
|
123
|
-
district: "Itaim",
|
124
|
-
street: "Avenida Faria Lima",
|
125
|
-
streetNumber: "2927",
|
126
|
-
zipCode: "01234000",
|
127
|
-
state: "SP",
|
128
|
-
country: "BRA"
|
129
|
-
}
|
130
143
|
}
|
131
144
|
end
|
132
145
|
|
@@ -145,8 +158,70 @@ describe Moip2::CustomerApi do
|
|
145
158
|
it { expect(created_customer.shipping_address).to_not be_nil }
|
146
159
|
it { expect(created_customer.shipping_address.zip_code).to eq "01234000" }
|
147
160
|
it { expect(created_customer._links).to_not be_nil }
|
148
|
-
it {
|
161
|
+
it {
|
162
|
+
expect(
|
163
|
+
created_customer._links.self.href,
|
164
|
+
).to eq "#{ENV['sandbox_url']}/v2/customers/CUS-4GESZSOAH7HX"
|
165
|
+
}
|
166
|
+
end
|
149
167
|
|
168
|
+
describe "#create credit card to customer" do
|
169
|
+
let(:credit_card) do
|
170
|
+
{
|
171
|
+
method: "CREDIT_CARD",
|
172
|
+
creditCard: {
|
173
|
+
expirationMonth: "05",
|
174
|
+
expirationYear: "22",
|
175
|
+
number: "5555666677778884",
|
176
|
+
cvc: "123",
|
177
|
+
holder: {
|
178
|
+
fullname: "Jose Portador da Silva",
|
179
|
+
birthdate: "1988-12-30",
|
180
|
+
taxDocument: {
|
181
|
+
type: "CPF",
|
182
|
+
number: "33333333333",
|
183
|
+
},
|
184
|
+
phone: {
|
185
|
+
countryCode: "55",
|
186
|
+
areaCode: "11",
|
187
|
+
number: "66778899",
|
188
|
+
},
|
189
|
+
},
|
190
|
+
},
|
191
|
+
}
|
192
|
+
end
|
193
|
+
|
194
|
+
let(:credit_card_added) do
|
195
|
+
VCR.use_cassette("create_credit_card_customer") do
|
196
|
+
customer_api.add_credit_card("CUS-4GESZSOAH7HX", credit_card)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
it { expect(credit_card_added.credit_card.id).to_not be_nil }
|
201
|
+
it { expect(credit_card_added.credit_card.brand).to eq "MASTERCARD" }
|
202
|
+
it { expect(credit_card_added.credit_card.first6).to eq "555566" }
|
203
|
+
it { expect(credit_card_added.credit_card.last4).to eq "8884" }
|
150
204
|
end
|
151
205
|
|
206
|
+
describe "#delete a credit card from customer" do
|
207
|
+
context "when credit card exists" do
|
208
|
+
let(:credit_card_deleted) do
|
209
|
+
VCR.use_cassette("delete_credit_card_customer") do
|
210
|
+
customer_api.delete_credit_card!("CRC-920F3Z3CTVN8")
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
it { expect(credit_card_deleted).to eq true }
|
215
|
+
end
|
216
|
+
|
217
|
+
context "when credit card doesn't exist" do
|
218
|
+
let(:credit_card_nonexistent) do
|
219
|
+
VCR.use_cassette("delete_nonexistent_credit_card_customer") do
|
220
|
+
customer_api.delete_credit_card!("CRC-450F3Z4CTVN8")
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
it { expect { credit_card_nonexistent }.to raise_error(Moip2::NotFoundError) }
|
225
|
+
end
|
226
|
+
end
|
152
227
|
end
|
data/spec/moip2/invoice_spec.rb
CHANGED
@@ -1,19 +1,36 @@
|
|
1
1
|
describe Moip2::InvoiceApi do
|
2
|
-
|
3
2
|
let(:invoice_api) { described_class.new sandbox_oauth_client }
|
4
3
|
|
5
|
-
let(:
|
4
|
+
let(:invoice_external_id_to_update) do
|
6
5
|
"INV-4517A209DDA9"
|
7
6
|
end
|
8
7
|
|
9
|
-
|
8
|
+
let(:invoice_external_id) do
|
9
|
+
"INV-4C26A14CF75B"
|
10
|
+
end
|
10
11
|
|
12
|
+
describe "#create" do
|
11
13
|
let(:invoice) do
|
12
14
|
{
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
invoiceAmount: 12610,
|
16
|
+
description: "teste",
|
17
|
+
customer: {
|
18
|
+
email: "vagner.vieira@moip.com.br",
|
19
|
+
},
|
20
|
+
checkoutPreferences: {
|
21
|
+
fundingInstruments: {
|
22
|
+
suppressBoleto: true,
|
23
|
+
},
|
24
|
+
installments: [
|
25
|
+
{
|
26
|
+
quantity: [
|
27
|
+
1,
|
28
|
+
2,
|
29
|
+
],
|
30
|
+
},
|
31
|
+
],
|
32
|
+
suppressShippingAddress: true,
|
33
|
+
},
|
17
34
|
}
|
18
35
|
end
|
19
36
|
|
@@ -24,50 +41,55 @@ describe Moip2::InvoiceApi do
|
|
24
41
|
end
|
25
42
|
|
26
43
|
it { expect(created_invoice.id).to_not be_nil }
|
27
|
-
it { expect(created_invoice.
|
28
|
-
it { expect(created_invoice.
|
29
|
-
it { expect(created_invoice.description).to eq "
|
30
|
-
|
44
|
+
it { expect(created_invoice.invoice_amount).to eq 12610 }
|
45
|
+
it { expect(created_invoice.customer.email).to eq "vagner.vieira@moip.com.br" }
|
46
|
+
it { expect(created_invoice.description).to eq "teste" }
|
47
|
+
it {
|
48
|
+
expect(
|
49
|
+
created_invoice.checkout_preferences.funding_instruments.suppress_boleto,
|
50
|
+
).to be_truthy
|
51
|
+
}
|
52
|
+
|
53
|
+
it { expect(created_invoice.checkout_preferences.suppress_shipping_address).to be_truthy }
|
31
54
|
end
|
32
55
|
|
33
56
|
describe "#show" do
|
34
|
-
|
35
57
|
let(:invoice) do
|
36
58
|
VCR.use_cassette("get_invoice") do
|
37
59
|
invoice_api.show invoice_external_id
|
38
60
|
end
|
39
61
|
end
|
40
62
|
|
41
|
-
it { expect(invoice.id).
|
42
|
-
it { expect(invoice.
|
43
|
-
it { expect(invoice.
|
44
|
-
it { expect(invoice.description).to eq "
|
45
|
-
|
63
|
+
it { expect(invoice.id).to_not be_nil }
|
64
|
+
it { expect(invoice.invoice_amount).to eq 12610 }
|
65
|
+
it { expect(invoice.customer.email).to eq "vagner.vieira@moip.com.br" }
|
66
|
+
it { expect(invoice.description).to eq "teste" }
|
67
|
+
it { expect(invoice.checkout_preferences.funding_instruments.suppress_boleto).to be_truthy }
|
68
|
+
it { expect(invoice.checkout_preferences.suppress_shipping_address).to be_truthy }
|
46
69
|
end
|
47
70
|
|
48
71
|
describe "#update" do
|
49
72
|
let(:update_params) do
|
50
73
|
{
|
51
74
|
orderExternalId: "ORD-NLQ916TW81TN",
|
52
|
-
customerExternalId: "CUS-GF45QI98NST1"
|
75
|
+
customerExternalId: "CUS-GF45QI98NST1",
|
53
76
|
}
|
54
77
|
end
|
55
78
|
|
56
79
|
let(:updated_invoice) do
|
57
80
|
VCR.use_cassette("update_invoice") do
|
58
|
-
invoice_api.update
|
81
|
+
invoice_api.update invoice_external_id_to_update, update_params
|
59
82
|
end
|
60
83
|
end
|
61
84
|
|
62
|
-
it { expect(updated_invoice.id).to eq "INV-4517A209DDA9"
|
85
|
+
it { expect(updated_invoice.id).to eq "INV-4517A209DDA9" }
|
63
86
|
|
64
|
-
it { expect(updated_invoice.order_external_id).to eq "ORD-NLQ916TW81TN"
|
65
|
-
it { expect(updated_invoice.customer_external_id).to eq "CUS-GF45QI98NST1"
|
87
|
+
it { expect(updated_invoice.order_external_id).to eq "ORD-NLQ916TW81TN" }
|
88
|
+
it { expect(updated_invoice.customer_external_id).to eq "CUS-GF45QI98NST1" }
|
66
89
|
|
67
90
|
it { expect(updated_invoice.email).to eq "caio.gama@moip.com.br" }
|
68
91
|
it { expect(updated_invoice.type).to eq "subscription" }
|
69
92
|
it { expect(updated_invoice.description).to eq "Assinatura da aula de desenho" }
|
70
|
-
|
71
93
|
end
|
72
94
|
|
73
95
|
describe "#list" do
|
@@ -78,18 +100,15 @@ describe Moip2::InvoiceApi do
|
|
78
100
|
end
|
79
101
|
|
80
102
|
context "request with results" do
|
81
|
-
|
82
|
-
let(:
|
83
|
-
let(:end_date) { '2015-03-31' }
|
103
|
+
let(:begin_date) { "2015-01-01" }
|
104
|
+
let(:end_date) { "2015-03-31" }
|
84
105
|
|
85
106
|
it { expect(result).to_not be_nil }
|
86
107
|
it { expect(result.invoices.size).to eq 2 }
|
87
|
-
it { expect(result.invoices[0].id).to eq
|
88
|
-
it { expect(result.invoices[0].account_id).to eq
|
89
|
-
it { expect(result.invoices[1].id).to eq
|
90
|
-
it { expect(result.invoices[1].account_id).to eq
|
108
|
+
it { expect(result.invoices[0].id).to eq "INV-635DC2BB9422" }
|
109
|
+
it { expect(result.invoices[0].account_id).to eq "MPA-MAROTO000000" }
|
110
|
+
it { expect(result.invoices[1].id).to eq "INV-635DC2BSHJ90" }
|
111
|
+
it { expect(result.invoices[1].account_id).to eq "MPA-MAROTO000000" }
|
91
112
|
end
|
92
|
-
|
93
113
|
end
|
94
|
-
|
95
114
|
end
|
data/spec/moip2/keys_spec.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
describe Moip2::KeysApi do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
2
|
+
let(:keys_api) { described_class.new sandbox_oauth_client }
|
3
|
+
|
4
|
+
describe "#show" do
|
5
|
+
let(:keys) do
|
6
|
+
VCR.use_cassette("get_keys") do
|
7
|
+
keys_api.show
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when shooting request by keys" do
|
12
|
+
it { expect(keys).not_to be_nil }
|
13
|
+
it { expect(keys.keys.basic_auth.secret).to eq "ABABABABABABABABABABABABABABABABABABABAB" }
|
14
|
+
it { expect(keys.keys.basic_auth.token).to eq "01010101010101010101010101010101" }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|