gmo 0.3.0 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.travis.yml +5 -9
  4. data/CHANGELOG.md +37 -1
  5. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_deposit_gets_data_about_a_deposit.yml +38 -0
  6. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  7. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_account_gets_data_about_an_account.yml +38 -0
  8. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_deposit_gets_data_about_a_deposit.yml +38 -0
  9. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  10. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_delete_account_gets_data_about_an_account.yml +38 -0
  11. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_account_gets_data_about_an_account.yml +38 -0
  12. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_balance_gets_data_about_balance.yml +38 -0
  13. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_deposit_gets_data_about_a_deposit.yml +38 -0
  14. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  15. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_update_account_gets_data_about_an_account.yml +38 -0
  16. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_brandtoken_gets_data_about_order.yml +108 -0
  17. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_cvs_cancel_gets_data_about_a_transaction.yml +63 -0
  18. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_brandtoken_gets_data_about_a_transaction.yml +38 -0
  19. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_docomo_gets_data_about_a_transaction.yml +35 -0
  20. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_rakuten_id_gets_data_about_a_transaction.yml +35 -0
  21. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_brandtoken_gets_data_about_a_transaction.yml +73 -0
  22. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_brandtoken_parameter_contains_Japanese_characters_should_correctly_handle_Japanese.yml +73 -0
  23. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_docomo_gets_data_about_a_transaction.yml +67 -0
  24. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_doesn_t_require_card_info_if_token_is_present.yml +69 -0
  25. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_rakuten_id_gets_data_about_a_transaction.yml +67 -0
  26. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_refund_tran_brandtoken_gets_data_about_a_transaction.yml +108 -0
  27. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_sales_tran_brandtoken_gets_data_about_a_transaction.yml +143 -0
  28. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_secure_tran_gets_data_about_a_transaction.yml +36 -0
  29. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_void_tran_brandtoken_gets_data_about_order.yml +108 -0
  30. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/secure_tran_request_params.yml +2 -0
  31. data/fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_exec_tran_brandtoken_got_data.yml +73 -0
  32. data/fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_trade_brandtoken_got_data.yml +108 -0
  33. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_delete_brandtoken_gets_data_about_a_brandtoken.yml +73 -0
  34. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_search_brandtoken_gets_data_about_a_brandtoken.yml +74 -0
  35. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_search_card_detail_by_member_id_gets_data_about_card_detail.yml +36 -0
  36. data/lib/gmo.rb +10 -3
  37. data/lib/gmo/const.rb +2502 -3
  38. data/lib/gmo/errors.rb +22 -4
  39. data/lib/gmo/remittance_api.rb +331 -0
  40. data/lib/gmo/shop_and_site_api.rb +77 -2
  41. data/lib/gmo/shop_api.rb +315 -5
  42. data/lib/gmo/site_api.rb +70 -3
  43. data/lib/gmo/version.rb +2 -2
  44. data/spec/gmo/{error_spec.rb → errors_spec.rb} +11 -2
  45. data/spec/gmo/remittance_api_spec.rb +506 -0
  46. data/spec/gmo/shop_and_site_api_spec.rb +83 -3
  47. data/spec/gmo/shop_api_spec.rb +429 -1
  48. data/spec/gmo/site_api_spec.rb +88 -1
  49. data/spec/support/config.example.yml +5 -0
  50. data/spec/support/config.yml +5 -0
  51. data/spec/support/config_loader.rb +1 -1
  52. data/spec/support/vcr.rb +9 -2
  53. metadata +41 -8
data/lib/gmo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GMO
2
- VERSION = "0.3.0"
3
- end
2
+ VERSION = "0.5.3"
3
+ end
@@ -16,10 +16,19 @@ describe GMO::Payment::APIError do
16
16
  it "is a GMO::Payment::Error" do
17
17
  GMO::Payment::APIError.new({}).should be_a(GMO::Payment::Error)
18
18
  end
19
+
20
+ context 'with error messages' do
21
+ let(:response) { {
22
+ "ErrCode" => "BA1|E01",
23
+ "ErrInfo" => "BA1040001|E01170001|100"
24
+ } }
25
+ subject { GMO::Payment::APIError.new(response) }
26
+ it { expect(subject.message).to eq "ErrCode=BA1|E01&ErrInfo=BA1040001|E01170001|100&ErrMessage=Bank ID is not specified|Card Number not specified|Card number Required check error" }
27
+ end
19
28
  end
20
29
 
21
30
  describe GMO::Payment::ServerError do
22
31
  it "is a GMO::Payment::Error" do
23
- GMO::Payment::ServerError.new(nil, nil).should be_a(GMO::Payment::Error)
32
+ GMO::Payment::ServerError.new(nil, nil).should be_a(GMO::Payment::Error)
24
33
  end
25
- end
34
+ end
@@ -0,0 +1,506 @@
1
+ # Encoding: UTF-8
2
+
3
+ require "spec_helper"
4
+
5
+ describe "GMO::Payment::RemittanceAPI" do
6
+
7
+ before(:each) do
8
+ @service ||= GMO::Payment::RemittanceAPI.new({
9
+ :shop_id => SPEC_CONF["remittance"]["shop_id"],
10
+ :shop_pass => SPEC_CONF["remittance"]["shop_pass"],
11
+ :host => SPEC_CONF["remittance"]["host"],
12
+ :locale => :ja
13
+
14
+ })
15
+ end
16
+
17
+ it "should raise an ArgumentError if no options passed" do
18
+ lambda {
19
+ service = GMO::Payment::RemittanceAPI.new()
20
+ }.should raise_error(ArgumentError)
21
+ end
22
+
23
+ it "has an attr_reader for shop_id" do
24
+ @service.shop_id.should == SPEC_CONF["remittance"]["shop_id"]
25
+ end
26
+
27
+ it "has an attr_reader for shop_pass" do
28
+ @service.shop_pass.should == SPEC_CONF["remittance"]["shop_pass"]
29
+ end
30
+
31
+ it "has an attr_reader for host" do
32
+ @service.host.should == SPEC_CONF["remittance"]["host"]
33
+ end
34
+
35
+ describe "#create_account" do
36
+ let(:do_api_call) {
37
+ @service.create_account({
38
+ :bank_id => "bank00001",
39
+ :bank_code => "0001",
40
+ :branch_code => "813",
41
+ :account_type => :normal,
42
+ :account_name => "An Yutzy",
43
+ :account_number => "0012345",
44
+ :branch_code_jp => "00567",
45
+ :account_number_jp => "01234567",
46
+ :free => "foobar"
47
+ })
48
+ }
49
+
50
+ it "gets data about an account", :vcr do
51
+ result = do_api_call
52
+ result["Bank_ID"].nil?.should_not be_truthy
53
+ result["Method"].nil?.should_not be_truthy
54
+ end
55
+
56
+ context 'with all required options' do
57
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
58
+ before { allow(GMO).to receive(:make_request) { response } }
59
+
60
+ it "makes request with correct parameters", :vcr do
61
+ path = "/api/AccountRegistration.idPass"
62
+ args = {
63
+ "Method" => 1,
64
+ "Bank_ID" => "bank00001",
65
+ "Bank_Code" => "0001",
66
+ "Branch_Code" => "813",
67
+ "Account_Type" => 1,
68
+ "Account_Name" => "An Yutzy",
69
+ "Account_Number" => "0012345",
70
+ "Branch_Code_Jpbank" => "00567",
71
+ "Account_Number_Jpbank" => "01234567",
72
+ "Free" => "foobar",
73
+ "Shop_ID" => @service.shop_id,
74
+ "Shop_Pass" => @service.shop_pass
75
+ }
76
+ verb = "post"
77
+ options = { :host => @service.host }
78
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
79
+ end
80
+
81
+ after { do_api_call }
82
+ end
83
+
84
+ it "got error if missing options", :vcr do
85
+ lambda {
86
+ result = @service.create_account()
87
+ }.should raise_error("Required bank_id, bank_code, branch_code, account_type, account_name, account_number were not provided.")
88
+ end
89
+ end
90
+
91
+ describe "#update_account" do
92
+ let(:do_api_call) {
93
+ @service.update_account({
94
+ :bank_id => "bank00001",
95
+ :bank_code => "0001",
96
+ :branch_code => "813",
97
+ :account_type => :normal,
98
+ :account_name => "An Yutzy",
99
+ :account_number => "0012345",
100
+ :branch_code_jp => "00567",
101
+ :account_number_jp => "01234567",
102
+ :free => "foobar"
103
+ })
104
+ }
105
+
106
+ it "gets data about an account", :vcr do
107
+ result = do_api_call
108
+ result["Bank_ID"].nil?.should_not be_truthy
109
+ result["Method"].nil?.should_not be_truthy
110
+ end
111
+
112
+ context 'with all required options' do
113
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
114
+ before { allow(GMO).to receive(:make_request) { response } }
115
+
116
+ it "makes request with correct parameters", :vcr do
117
+ path = "/api/AccountRegistration.idPass"
118
+ args = {
119
+ "Method" => 2,
120
+ "Bank_ID" => "bank00001",
121
+ "Bank_Code" => "0001",
122
+ "Branch_Code" => "813",
123
+ "Account_Type" => 1,
124
+ "Account_Name" => "An Yutzy",
125
+ "Account_Number" => "0012345",
126
+ "Branch_Code_Jpbank" => "00567",
127
+ "Account_Number_Jpbank" => "01234567",
128
+ "Free" => "foobar",
129
+ "Shop_ID" => @service.shop_id,
130
+ "Shop_Pass" => @service.shop_pass
131
+ }
132
+ verb = "post"
133
+ options = { :host => @service.host }
134
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
135
+ end
136
+
137
+ after { do_api_call }
138
+ end
139
+
140
+ it "got error if missing options", :vcr do
141
+ lambda {
142
+ result = @service.create_account()
143
+ }.should raise_error("Required bank_id, bank_code, branch_code, account_type, account_name, account_number were not provided.")
144
+ end
145
+ end
146
+
147
+ describe "#delete_account" do
148
+ let(:do_api_call) { @service.delete_account(bank_id: "bank00001") }
149
+
150
+ it "gets data about an account", :vcr do
151
+ result = do_api_call
152
+ result["Bank_ID"].nil?.should_not be_truthy
153
+ result["Method"].nil?.should_not be_truthy
154
+ end
155
+
156
+ context 'with all required options' do
157
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
158
+ before { allow(GMO).to receive(:make_request) { response } }
159
+
160
+ it "makes request with correct parameters", :vcr do
161
+ path = "/api/AccountRegistration.idPass"
162
+ args = {
163
+ "Method" => 3,
164
+ "Bank_ID" => "bank00001",
165
+ "Shop_ID" => @service.shop_id,
166
+ "Shop_Pass" => @service.shop_pass
167
+ }
168
+ verb = "post"
169
+ options = { :host => @service.host }
170
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
171
+ end
172
+
173
+ after { do_api_call }
174
+ end
175
+
176
+ it "got error if missing options", :vcr do
177
+ lambda {
178
+ result = @service.delete_account()
179
+ }.should raise_error("Required bank_id were not provided.")
180
+ end
181
+ end
182
+
183
+ describe "#search_account" do
184
+ let(:do_api_call) { @service.search_account(:bank_id => "bank00001") }
185
+
186
+ it "gets data about an account", :vcr do
187
+ result = do_api_call
188
+ result["Bank_ID"].nil?.should_not be_truthy
189
+ result["Delete_Flag"].nil?.should_not be_truthy
190
+ result["Bank_Name"].nil?.should_not be_truthy
191
+ result["Bank_Code"].nil?.should_not be_truthy
192
+ result["Branch_Name"].nil?.should_not be_truthy
193
+ result["Branch_Code"].nil?.should_not be_truthy
194
+ result["Account_Type"].nil?.should_not be_truthy
195
+ result["Account_Number"].nil?.should_not be_truthy
196
+ result["Account_Name"].nil?.should_not be_truthy
197
+ result["Free"].nil?.should_not be_truthy
198
+ result["Branch_Code_Jpbank"].nil?.should_not be_truthy
199
+ result["Account_Number_Jpbank"].nil?.should_not be_truthy
200
+ end
201
+
202
+ context 'with all required options' do
203
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
204
+ before { allow(GMO).to receive(:make_request) { response } }
205
+
206
+ it "makes request with correct parameters", :vcr do
207
+ path = "/api/AccountSearch.idPass"
208
+ args = {
209
+ "Bank_ID" => "bank00001",
210
+ "Shop_ID" => @service.shop_id,
211
+ "Shop_Pass" => @service.shop_pass
212
+ }
213
+ verb = "post"
214
+ options = { :host => @service.host }
215
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
216
+ end
217
+
218
+ after { do_api_call }
219
+ end
220
+
221
+ it "got error if missing options", :vcr do
222
+ lambda {
223
+ result = @service.search_account()
224
+ }.should raise_error("Required bank_id were not provided.")
225
+ end
226
+ end
227
+
228
+ describe "#create_deposit" do
229
+ let(:do_api_call) {
230
+ @service.create_deposit({
231
+ :bank_id => "bank00001",
232
+ :deposit_id => "dep00001",
233
+ :amount => "1000"
234
+ })
235
+ }
236
+
237
+ it "gets data about a deposit", :vcr do
238
+ result = do_api_call
239
+ result["Bank_ID"].nil?.should_not be_truthy
240
+ result["Deposit_ID"].nil?.should_not be_truthy
241
+ result["Method"].nil?.should_not be_truthy
242
+ result["Amount"].nil?.should_not be_truthy
243
+ result["Bank_Fee"].nil?.should_not be_truthy
244
+ end
245
+
246
+ context 'with all required options' do
247
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
248
+ before { allow(GMO).to receive(:make_request) { response } }
249
+
250
+ it "makes request with correct parameters", :vcr do
251
+ path = "/api/DepositRegistration.idPass"
252
+ args = {
253
+ "Method" => 1,
254
+ "Bank_ID" => "bank00001",
255
+ "Deposit_ID" => "dep00001",
256
+ "Amount" => "1000",
257
+ "Shop_ID" => @service.shop_id,
258
+ "Shop_Pass" => @service.shop_pass
259
+ }
260
+ verb = "post"
261
+ options = { :host => @service.host }
262
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
263
+ end
264
+
265
+ after { do_api_call }
266
+ end
267
+
268
+ it "got error if missing options", :vcr do
269
+ lambda {
270
+ result = @service.create_deposit()
271
+ }.should raise_error("Required bank_id, deposit_id, amount were not provided.")
272
+ end
273
+ end
274
+
275
+ describe "#cancel_deposit" do
276
+ let(:do_api_call) {
277
+ @service.cancel_deposit({
278
+ :bank_id => "bank00001",
279
+ :deposit_id => "dep00001",
280
+ })
281
+ }
282
+
283
+ it "gets data about a deposit", :vcr do
284
+ result = do_api_call
285
+ result["Bank_ID"].nil?.should_not be_truthy
286
+ result["Deposit_ID"].nil?.should_not be_truthy
287
+ result["Method"].nil?.should_not be_truthy
288
+ end
289
+
290
+ context 'with all required options' do
291
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
292
+ before { allow(GMO).to receive(:make_request) { response } }
293
+
294
+ it "makes request with correct parameters", :vcr do
295
+ path = "/api/DepositRegistration.idPass"
296
+ args = {
297
+ "Method" => 2,
298
+ "Bank_ID" => "bank00001",
299
+ "Deposit_ID" => "dep00001",
300
+ "Shop_ID" => @service.shop_id,
301
+ "Shop_Pass" => @service.shop_pass
302
+ }
303
+ verb = "post"
304
+ options = { :host => @service.host }
305
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
306
+ end
307
+
308
+ after { do_api_call }
309
+ end
310
+
311
+ it "got error if missing options", :vcr do
312
+ lambda {
313
+ result = @service.cancel_deposit()
314
+ }.should raise_error("Required bank_id, deposit_id were not provided.")
315
+ end
316
+ end
317
+
318
+ describe "#search_deposit" do
319
+ let(:do_api_call) { @service.search_deposit(:deposit_id => "dep00001") }
320
+
321
+ it "gets data about a deposit", :vcr do
322
+ result = do_api_call
323
+ result["Bank_ID"].nil?.should_not be_truthy
324
+ result["Deposit_ID"].nil?.should_not be_truthy
325
+ result["Bank_Name"].nil?.should_not be_truthy
326
+ result["Bank_Code"].nil?.should_not be_truthy
327
+ result["Branch_Name"].nil?.should_not be_truthy
328
+ result["Branch_Code"].nil?.should_not be_truthy
329
+ result["Account_Type"].nil?.should_not be_truthy
330
+ result["Account_Number"].nil?.should_not be_truthy
331
+ result["Account_Name"].nil?.should_not be_truthy
332
+ result["Free"].nil?.should_not be_truthy
333
+ result["Amount"].nil?.should_not be_truthy
334
+ result["Bank_Fee"].nil?.should_not be_truthy
335
+ result["Result"].nil?.should_not be_truthy
336
+ result["Branch_Code_Jpbank"].nil?.should_not be_truthy
337
+ result["Account_Number_Jpbank"].nil?.should_not be_truthy
338
+ result["Deposit_Date"].nil?.should_not be_truthy
339
+ result["Result_Detail"].nil?.should_not be_truthy
340
+ end
341
+
342
+ context 'with all required options' do
343
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
344
+ before { allow(GMO).to receive(:make_request) { response } }
345
+
346
+ it "makes request with correct parameters", :vcr do
347
+ path = "/api/DepositSearch.idPass"
348
+ args = {
349
+ "Deposit_ID" => "dep00001",
350
+ "Shop_ID" => @service.shop_id,
351
+ "Shop_Pass" => @service.shop_pass
352
+ }
353
+ verb = "post"
354
+ options = { :host => @service.host }
355
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
356
+ end
357
+
358
+ after { do_api_call }
359
+ end
360
+
361
+ it "got error if missing options", :vcr do
362
+ lambda {
363
+ result = @service.search_deposit()
364
+ }.should raise_error("Required deposit_id were not provided.")
365
+ end
366
+ end
367
+
368
+ describe "#search_balance" do
369
+ let(:do_api_call) { @service.search_balance }
370
+ it "gets data about balance", :vcr do
371
+ result = do_api_call
372
+ result["Shop_ID"].nil?.should_not be_truthy
373
+ result["Balance"].nil?.should_not be_truthy
374
+ result["Balance_Forecast"].nil?.should_not be_truthy
375
+ end
376
+ end
377
+
378
+ describe "#create_mail_deposit" do
379
+ let(:do_api_call) {
380
+ @service.create_mail_deposit({
381
+ :deposit_id => "dep00001",
382
+ :deposit_email => "anyutzy@demo.com",
383
+ :amount => 1000,
384
+ :deposit_account_name => "An Yutzy",
385
+ :expire => 5,
386
+ :deposit_shop_email => "anyutzy@demo.com"
387
+ })
388
+ }
389
+
390
+ it "gets data about a mail deposit", :vcr do
391
+ result = do_api_call
392
+ result["Deposit_ID"].nil?.should_not be_truthy
393
+ result["Method"].nil?.should_not be_truthy
394
+ result["Amount"].nil?.should_not be_truthy
395
+ result["Expire"].nil?.should_not be_truthy
396
+ end
397
+
398
+ context 'with all required options' do
399
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
400
+ before { allow(GMO).to receive(:make_request) { response } }
401
+
402
+ it "makes request with correct parameters", :vcr do
403
+ path = "/api/MailDepositRegistration.idPass"
404
+ args = {
405
+ "Deposit_ID" => "dep00001",
406
+ "Mail_Address" => "anyutzy@demo.com",
407
+ "Amount" => 1000,
408
+ "Mail_Deposit_Account_Name" => "An Yutzy",
409
+ "Expire" => 5,
410
+ "Shop_Mail_Address" => "anyutzy@demo.com",
411
+ "Method" => 1,
412
+ "Shop_ID" => @service.shop_id,
413
+ "Shop_Pass" => @service.shop_pass
414
+ }
415
+ verb = "post"
416
+ options = { :host => @service.host }
417
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
418
+ end
419
+
420
+ after { do_api_call }
421
+ end
422
+
423
+ it "got error if missing options", :vcr do
424
+ lambda {
425
+ result = @service.create_mail_deposit()
426
+ }.should raise_error("Required deposit_id, deposit_email, amount, deposit_account_name, expire, deposit_shop_email were not provided.")
427
+ end
428
+ end
429
+
430
+ describe "#cancel_mail_deposit" do
431
+ let(:do_api_call) { @service.cancel_mail_deposit(deposit_id: "dep00001") }
432
+
433
+ it "gets data about a mail deposit", :vcr do
434
+ result = do_api_call
435
+ result["Deposit_ID"].nil?.should_not be_truthy
436
+ result["Method"].nil?.should_not be_truthy
437
+ end
438
+
439
+ context 'with all required options' do
440
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
441
+ before { allow(GMO).to receive(:make_request) { response } }
442
+
443
+ it "makes request with correct parameters", :vcr do
444
+ path = "/api/MailDepositRegistration.idPass"
445
+ args = {
446
+ "Deposit_ID" => "dep00001",
447
+ "Method" => 2,
448
+ "Shop_ID" => @service.shop_id,
449
+ "Shop_Pass" => @service.shop_pass
450
+ }
451
+ verb = "post"
452
+ options = { :host => @service.host }
453
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
454
+ end
455
+
456
+ after { do_api_call }
457
+ end
458
+
459
+ it "got error if missing options", :vcr do
460
+ lambda {
461
+ result = @service.cancel_mail_deposit()
462
+ }.should raise_error("Required deposit_id were not provided.")
463
+ end
464
+ end
465
+
466
+ describe "#search_mail_deposit" do
467
+ let(:do_api_call) { @service.search_mail_deposit(deposit_id: "dep00001") }
468
+
469
+ it "gets data about a mail deposit", :vcr do
470
+ result = do_api_call
471
+ result["Deposit_ID"].nil?.should_not be_truthy
472
+ result["Mail_Address"].should eq('anyutzy+test@demo.com')
473
+ result["Shop_Mail_Address"].nil?.should_not be_truthy
474
+ result["Account_Name"].nil?.should_not be_truthy
475
+ result["Amount"].nil?.should_not be_truthy
476
+ result["Expire"].nil?.should_not be_truthy
477
+ result["Status"].nil?.should_not be_truthy
478
+ end
479
+
480
+ context 'with all required options' do
481
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
482
+ before { allow(GMO).to receive(:make_request) { response } }
483
+
484
+ it "makes request with correct parameters", :vcr do
485
+ path = "/api/MailDepositSearch.idPass"
486
+ args = {
487
+ "Deposit_ID" => "dep00001",
488
+ "Shop_ID" => @service.shop_id,
489
+ "Shop_Pass" => @service.shop_pass
490
+ }
491
+ verb = "post"
492
+ options = { :host => @service.host }
493
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
494
+ end
495
+
496
+ after { do_api_call }
497
+ end
498
+
499
+ it "got error if missing options", :vcr do
500
+ lambda {
501
+ result = @service.search_mail_deposit()
502
+ }.should raise_error("Required deposit_id were not provided.")
503
+ end
504
+ end
505
+
506
+ end