moip2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +4 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +9 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +129 -0
  10. data/Rakefile +1 -0
  11. data/lib/moip2/api.rb +24 -0
  12. data/lib/moip2/auth/basic.rb +19 -0
  13. data/lib/moip2/auth/oauth.rb +18 -0
  14. data/lib/moip2/client.rb +107 -0
  15. data/lib/moip2/customer_api.rb +24 -0
  16. data/lib/moip2/exceptions/invalid_enviroment_error.rb +6 -0
  17. data/lib/moip2/invoice_api.rb +32 -0
  18. data/lib/moip2/keys_api.rb +17 -0
  19. data/lib/moip2/multi_order_api.rb +23 -0
  20. data/lib/moip2/multi_payment_api.rb +17 -0
  21. data/lib/moip2/order_api.rb +25 -0
  22. data/lib/moip2/payment_api.rb +15 -0
  23. data/lib/moip2/resource/customer.rb +16 -0
  24. data/lib/moip2/resource/invoice.rb +14 -0
  25. data/lib/moip2/resource/keys.rb +14 -0
  26. data/lib/moip2/resource/multi_order.rb +25 -0
  27. data/lib/moip2/resource/multi_payment.rb +11 -0
  28. data/lib/moip2/resource/order.rb +25 -0
  29. data/lib/moip2/resource/payment.rb +13 -0
  30. data/lib/moip2/response.rb +20 -0
  31. data/lib/moip2/version.rb +3 -0
  32. data/lib/moip2.rb +74 -0
  33. data/moip2.gemspec +30 -0
  34. data/spec/moip2/api_spec.rb +25 -0
  35. data/spec/moip2/auth/basic_spec.rb +9 -0
  36. data/spec/moip2/auth/oauth_spec.rb +9 -0
  37. data/spec/moip2/client_spec.rb +133 -0
  38. data/spec/moip2/customer_api_spec.rb +152 -0
  39. data/spec/moip2/invoice_spec.rb +95 -0
  40. data/spec/moip2/keys_spec.rb +19 -0
  41. data/spec/moip2/multi_order_api_spec.rb +198 -0
  42. data/spec/moip2/order_api_spec.rb +138 -0
  43. data/spec/moip2/payment_api_spec.rb +43 -0
  44. data/spec/moip2/resource/order_spec.rb +47 -0
  45. data/spec/moip2/response_spec.rb +51 -0
  46. data/spec/moip2_spec.rb +50 -0
  47. data/spec/spec_helper.rb +113 -0
  48. data/vcr_cassettes/create_customer.yml +43 -0
  49. data/vcr_cassettes/create_customer_with_funding_instrument.yml +45 -0
  50. data/vcr_cassettes/create_invoice.yml +42 -0
  51. data/vcr_cassettes/create_mulit_order_success.yml +142 -0
  52. data/vcr_cassettes/create_multi_order_fail.yml +43 -0
  53. data/vcr_cassettes/create_order_fail.yml +43 -0
  54. data/vcr_cassettes/create_order_success.yml +47 -0
  55. data/vcr_cassettes/create_payment_success.yml +39 -0
  56. data/vcr_cassettes/get_customer.yml +42 -0
  57. data/vcr_cassettes/get_invoice.yml +41 -0
  58. data/vcr_cassettes/get_keys.yml +42 -0
  59. data/vcr_cassettes/list_invoices.yml +43 -0
  60. data/vcr_cassettes/show_multi_order.yml +132 -0
  61. data/vcr_cassettes/show_multi_order_not_found.yml +40 -0
  62. data/vcr_cassettes/show_order.yml +43 -0
  63. data/vcr_cassettes/show_order_not_found.yml +38 -0
  64. data/vcr_cassettes/update_invoice.yml +41 -0
  65. data/wercker.yml +48 -0
  66. metadata +238 -0
@@ -0,0 +1,20 @@
1
+ module Moip2
2
+
3
+ class Response < SimpleDelegator
4
+
5
+ def initialize(resp, json)
6
+ super(RecursiveOpenStruct.new(json, :recurse_over_arrays => true))
7
+ @resp = resp
8
+ end
9
+
10
+ def success?
11
+ (200..299).include? @resp.code.to_i
12
+ end
13
+
14
+ def client_error?
15
+ (400..499).include? @resp.code.to_i
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,3 @@
1
+ module Moip2
2
+ VERSION = "0.1.0"
3
+ end
data/lib/moip2.rb ADDED
@@ -0,0 +1,74 @@
1
+ require "httparty"
2
+ require "delegate"
3
+ require "recursive-open-struct"
4
+
5
+ require "moip2/version"
6
+
7
+ require "moip2/auth/basic"
8
+ require "moip2/auth/oauth"
9
+
10
+ require "moip2/resource/order"
11
+ require "moip2/resource/multi_order"
12
+ require "moip2/resource/payment"
13
+ require "moip2/resource/multi_payment"
14
+ require "moip2/resource/customer"
15
+ require "moip2/resource/invoice"
16
+ require "moip2/resource/keys"
17
+
18
+ require "moip2/response"
19
+ require "moip2/client"
20
+ require "moip2/order_api"
21
+ require "moip2/multi_order_api"
22
+ require "moip2/payment_api"
23
+ require "moip2/multi_payment_api"
24
+ require "moip2/customer_api"
25
+ require "moip2/invoice_api"
26
+ require "moip2/api"
27
+
28
+ require "moip2/keys_api"
29
+
30
+ require "moip2/exceptions/invalid_enviroment_error"
31
+
32
+ module Moip2
33
+
34
+ class << self
35
+
36
+ VALID_ENVS = %i(sandbox production)
37
+
38
+ def env=(env)
39
+ raise InvalidEnviromentError unless VALID_ENVS.include?(env.to_sym)
40
+ @env = env
41
+ end
42
+
43
+ def env
44
+ @env ||= :sandbox
45
+ end
46
+
47
+ def auth=(credentials)
48
+ @credentials = credentials
49
+ end
50
+
51
+ def auth
52
+ @credentials
53
+ end
54
+
55
+ def opts=(opts = {})
56
+ @opts = opts
57
+ end
58
+
59
+ def opts
60
+ @opts ||= {}
61
+ end
62
+
63
+ def new
64
+ raise "Auth is not set" unless auth
65
+
66
+ Api.new Client.new(env, auth)
67
+ end
68
+
69
+ end
70
+
71
+ class NotFoundError < StandardError
72
+ end
73
+
74
+ end
data/moip2.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'moip2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "moip2"
8
+ spec.version = Moip2::VERSION
9
+ spec.authors = ["Rodrigo Saito", "Danillo Souza", "Caio Gama"]
10
+ spec.email = ["rodrigo.saito@moip.com.br", "danillo.souza@moip.com.br", "caio.gama@moip.com.br"]
11
+ spec.summary = %q{Ruby client for moip v2 api}
12
+ spec.description = %q{Ruby client for moip v2 api}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "httparty"
22
+ spec.add_dependency "recursive-open-struct"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.5"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec", "~> 3.0.0.beta2"
27
+ spec.add_development_dependency "vcr"
28
+ spec.add_development_dependency "webmock"
29
+ spec.add_development_dependency "guard-rspec"
30
+ end
@@ -0,0 +1,25 @@
1
+ describe Moip2::Api do
2
+
3
+ let(:auth) { Moip2::Auth::Basic.new('', '') }
4
+ let(:client) { Moip2::Client.new(:sandbox, auth) }
5
+ let(:api) { described_class.new client }
6
+
7
+ describe "#order" do
8
+
9
+ it "returns an OrderApi" do
10
+ expect(api.order).to be_a(Moip2::OrderApi)
11
+ end
12
+
13
+ end
14
+
15
+ describe "#payment" do
16
+ it "returns a PaymentApi" do
17
+ expect(api.payment).to be_a(Moip2::PaymentApi)
18
+ end
19
+ end
20
+
21
+ describe "#invoice" do
22
+ it { expect(api.invoice).to be_a Moip2::InvoiceApi }
23
+ end
24
+
25
+ end
@@ -0,0 +1,9 @@
1
+ describe Moip2::Auth::Basic do
2
+
3
+ let(:basic) { described_class.new('01010101010101010101010101010101', 'ABABABABABABABABABABABABABABABABABABABAB') }
4
+
5
+ it "builds authorization header" do
6
+ expect(basic.header).to eq "Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg=="
7
+ end
8
+
9
+ end
@@ -0,0 +1,9 @@
1
+ describe Moip2::Auth::OAuth do
2
+ let(:oauth_with_text) { described_class.new "OAuth d63tz2xwyu0ewrembove4j5cbv2otpd" }
3
+ let(:oauth_without_text) { described_class.new "d63tz2xwyu0ewrembove4j5cbv2otpd" }
4
+
5
+ describe ".header" do
6
+ it { expect(oauth_with_text.header).to eq "OAuth d63tz2xwyu0ewrembove4j5cbv2otpd" }
7
+ it { expect(oauth_without_text.header).to eq "OAuth d63tz2xwyu0ewrembove4j5cbv2otpd" }
8
+ end
9
+ end
@@ -0,0 +1,133 @@
1
+ describe Moip2::Client do
2
+
3
+ let(:auth) do
4
+ Moip2::Auth::Basic.new("TOKEN", "SECRET")
5
+ end
6
+
7
+ let(:oauth) do
8
+ Moip2::Auth::OAuth.new "d63tz2xwyu0ewrembove4j5cbv2otpd"
9
+ end
10
+
11
+ describe "initialize env with string" do
12
+ let(:client) do
13
+ described_class.new "sandbox", auth
14
+ end
15
+
16
+ it { expect(client.env).to eq :sandbox }
17
+ end
18
+
19
+ describe "initialize on sandbox with OAuth" do
20
+
21
+ let(:client) do
22
+ described_class.new :sandbox, auth
23
+ end
24
+
25
+ let(:client) { described_class.new :sandbox, oauth }
26
+ it { expect(client.uri).to eq "https://test.moip.com.br" }
27
+ it { expect(client.env).to eq :sandbox }
28
+ it { expect(client.opts[:headers]["Authorization"]).to eq "OAuth d63tz2xwyu0ewrembove4j5cbv2otpd" }
29
+
30
+ end
31
+
32
+ describe "initialize on production" do
33
+ let(:client) do
34
+ described_class.new :production, oauth
35
+ end
36
+
37
+ it { expect(client.uri).to eq "https://api.moip.com.br" }
38
+ it { expect(client.env).to eq :production }
39
+ it { expect(client.opts[:headers]["Authorization"]).to eq "OAuth d63tz2xwyu0ewrembove4j5cbv2otpd" }
40
+ end
41
+
42
+ describe "initialize on sandbox with base_uri and OAuth" do
43
+
44
+ before do
45
+ ENV['base_uri'] = "http://localhost:5000"
46
+ end
47
+
48
+ let(:client) do
49
+ described_class.new :sandbox, oauth
50
+ end
51
+
52
+
53
+ it { expect(client.uri).to eq "http://localhost:5000" }
54
+ it { expect(client.env).to eq :sandbox }
55
+ it { expect(client.opts[:headers]["Authorization"]).to eq "OAuth d63tz2xwyu0ewrembove4j5cbv2otpd" }
56
+
57
+ end
58
+
59
+ describe "initialize on production with base_uri and OAuth" do
60
+
61
+ before do
62
+ ENV['base_uri'] = "http://localhost:5000"
63
+ end
64
+
65
+ let(:client) do
66
+ described_class.new :production, oauth
67
+ end
68
+
69
+ it { expect(client.uri).to eq "http://localhost:5000" }
70
+ it { expect(client.env).to eq :production }
71
+ it { expect(client.opts[:headers]["Authorization"]).to eq "OAuth d63tz2xwyu0ewrembove4j5cbv2otpd" }
72
+
73
+ end
74
+
75
+ describe "initialize on sandbox with base_uri" do
76
+
77
+ before do
78
+ ENV['base_uri'] = "http://localhost:5000"
79
+ end
80
+
81
+ let(:client) do
82
+ described_class.new :sandbox, auth
83
+ end
84
+
85
+
86
+ it { expect(client.uri).to eq "http://localhost:5000" }
87
+ it { expect(client.env).to eq :sandbox }
88
+ it { expect(client.opts[:headers]["Authorization"]).to eq "Basic VE9LRU46U0VDUkVU" }
89
+
90
+ end
91
+
92
+ describe "initialize on production with base_uri" do
93
+
94
+ before do
95
+ ENV['base_uri'] = "http://localhost:5000"
96
+ end
97
+
98
+ let(:client) do
99
+ described_class.new :production, auth
100
+ end
101
+
102
+ it { expect(client.uri).to eq "http://localhost:5000" }
103
+ it { expect(client.env).to eq :production }
104
+ it { expect(client.opts[:headers]["Authorization"]).to eq "Basic VE9LRU46U0VDUkVU" }
105
+
106
+ end
107
+
108
+ describe "initialize on sandbox" do
109
+
110
+ before do
111
+ ENV['base_uri'] = nil
112
+ end
113
+
114
+ let(:client) do
115
+ described_class.new :sandbox, auth
116
+ end
117
+
118
+ it { expect(client.uri).to eq "https://test.moip.com.br" }
119
+ it { expect(client.env).to eq :sandbox }
120
+ it { expect(client.opts[:headers]["Authorization"]).to eq "Basic VE9LRU46U0VDUkVU" }
121
+ end
122
+
123
+ describe "initialize on production" do
124
+ let(:client) do
125
+ described_class.new :production, auth
126
+ end
127
+
128
+ it { expect(client.uri).to eq "https://api.moip.com.br" }
129
+ it { expect(client.env).to eq :production }
130
+ it { expect(client.opts[:headers]["Authorization"]).to eq "Basic VE9LRU46U0VDUkVU" }
131
+ end
132
+
133
+ end
@@ -0,0 +1,152 @@
1
+ describe Moip2::CustomerApi do
2
+
3
+ let(:customer_api) { described_class.new(sandbox_client) }
4
+
5
+ describe "#show" do
6
+
7
+ let(:customer_external_id) { "CUS-B6LE6HLFFXKF" }
8
+
9
+ let(:customer) do
10
+ VCR.use_cassette("get_customer") do
11
+ customer_api.show(customer_external_id)
12
+ end
13
+ end
14
+
15
+ it { expect(customer.id).to eq customer_external_id }
16
+ it { expect(customer.own_id).to eq "your_customer_own_id" }
17
+ it { expect(customer.email).to eq "john.doe@mailinator.com" }
18
+ it { expect(customer.funding_instrument).to_not be_nil }
19
+ it { expect(customer.funding_instrument.credit_card.id).to eq "CRC-OQPJYLGZOY7P" }
20
+ it { expect(customer.funding_instrument.credit_card.brand).to eq "VISA" }
21
+ it { expect(customer.phone).to_not be_nil }
22
+ it { expect(customer.tax_document).to_not be_nil }
23
+ it { expect(customer.tax_document.type).to eq "CPF" }
24
+ it { expect(customer.shipping_address).to_not be_nil }
25
+ it { expect(customer.shipping_address.zip_code).to eq "01234000" }
26
+ it { expect(customer._links).to_not be_nil }
27
+ it { expect(customer._links.self.href).to eq "https://test.moip.com.br/v2/customers/CUS-B6LE6HLFFXKF" }
28
+
29
+ end
30
+
31
+ describe "#create with funding instrument" do
32
+
33
+ let(:customer_with_funding_instrument) do
34
+ {
35
+ ownId: "meu_id_de_cliente",
36
+ fullname: "Jose Silva",
37
+ email: "josedasilva@email.com",
38
+ phone: {
39
+ areaCode: "11",
40
+ number: "66778899"
41
+ },
42
+ birthDate: "1988-12-30",
43
+ taxDocument: {
44
+ type: "CPF",
45
+ number: "22222222222"
46
+ },
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
+ },
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
+ },
70
+ phone: {
71
+ areaCode: "11",
72
+ number: "66778899"
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ end
79
+
80
+
81
+ let(:created_customer_with_funding_instrument) do
82
+ VCR.use_cassette("create_customer_with_funding_instrument") do
83
+ customer_api.create customer_with_funding_instrument
84
+ end
85
+ end
86
+
87
+ it { expect(created_customer_with_funding_instrument.id).to eq "CUS-E5CO735TBXTI" }
88
+ it { expect(created_customer_with_funding_instrument.own_id).to eq "meu_id_de_cliente" }
89
+ it { expect(created_customer_with_funding_instrument.email).to eq "josedasilva@email.com" }
90
+ it { expect(created_customer_with_funding_instrument.funding_instrument).to_not be_nil }
91
+ it { expect(created_customer_with_funding_instrument.funding_instrument.credit_card.id).to eq "CRC-F5DR8SVINCUI" }
92
+ it { expect(created_customer_with_funding_instrument.funding_instrument.credit_card.brand).to eq "VISA" }
93
+ it { expect(created_customer_with_funding_instrument.phone).to_not be_nil }
94
+ it { expect(created_customer_with_funding_instrument.tax_document).to_not be_nil }
95
+ it { expect(created_customer_with_funding_instrument.tax_document.type).to eq "CPF" }
96
+ it { expect(created_customer_with_funding_instrument.shipping_address).to_not be_nil }
97
+ it { expect(created_customer_with_funding_instrument.shipping_address.zip_code).to eq "01234000" }
98
+ it { expect(created_customer_with_funding_instrument._links).to_not be_nil }
99
+ it { expect(created_customer_with_funding_instrument._links.self.href).to eq "https://test.moip.com.br/v2/customers/CUS-E5CO735TBXTI" }
100
+
101
+ end
102
+
103
+ describe "#create without funding instrument" do
104
+
105
+ let(:customer) do
106
+ {
107
+ ownId: "meu_id_sandbox_1231234",
108
+ fullname: "Jose Silva",
109
+ email: "jose_silva0@email.com",
110
+ birthDate: "1988-12-30",
111
+ taxDocument: {
112
+ type: "CPF",
113
+ number: "22222222222"
114
+ },
115
+ phone: {
116
+ countryCode: "55",
117
+ areaCode: "11",
118
+ number: "66778899"
119
+ },
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
+ }
131
+ end
132
+
133
+ let(:created_customer) do
134
+ VCR.use_cassette("create_customer") do
135
+ customer_api.create customer
136
+ end
137
+ end
138
+
139
+ it { expect(created_customer.id).to eq "CUS-4GESZSOAH7HX" }
140
+ it { expect(created_customer.own_id).to eq "meu_id_sandbox_1231234" }
141
+ it { expect(created_customer.email).to eq "jose_silva0@email.com" }
142
+ it { expect(created_customer.phone).to_not be_nil }
143
+ it { expect(created_customer.tax_document).to_not be_nil }
144
+ it { expect(created_customer.tax_document.type).to eq "CPF" }
145
+ it { expect(created_customer.shipping_address).to_not be_nil }
146
+ it { expect(created_customer.shipping_address.zip_code).to eq "01234000" }
147
+ it { expect(created_customer._links).to_not be_nil }
148
+ it { expect(created_customer._links.self.href).to eq "https://test.moip.com.br/v2/customers/CUS-4GESZSOAH7HX" }
149
+
150
+ end
151
+
152
+ end
@@ -0,0 +1,95 @@
1
+ describe Moip2::InvoiceApi do
2
+
3
+ let(:invoice_api) { described_class.new sandbox_oauth_client }
4
+
5
+ let(:invoice_external_id) do
6
+ "INV-4517A209DDA9"
7
+ end
8
+
9
+ describe "#create" do
10
+
11
+ let(:invoice) do
12
+ {
13
+ amount: 13470,
14
+ email: "caio.gama@moip.com.br",
15
+ invoiceType: :subscription,
16
+ description: "Assinatura da aula de desenho"
17
+ }
18
+ end
19
+
20
+ let(:created_invoice) do
21
+ VCR.use_cassette("create_invoice") do
22
+ invoice_api.create invoice
23
+ end
24
+ end
25
+
26
+ it { expect(created_invoice.id).to_not be_nil }
27
+ it { expect(created_invoice.email).to eq "caio.gama@moip.com.br" }
28
+ it { expect(created_invoice.type).to eq "subscription" }
29
+ it { expect(created_invoice.description).to eq "Assinatura da aula de desenho" }
30
+
31
+ end
32
+
33
+ describe "#show" do
34
+
35
+ let(:invoice) do
36
+ VCR.use_cassette("get_invoice") do
37
+ invoice_api.show invoice_external_id
38
+ end
39
+ end
40
+
41
+ it { expect(invoice.id).to eq "INV-4517A209DDA9" }
42
+ it { expect(invoice.email).to eq "caio.gama@moip.com.br" }
43
+ it { expect(invoice.type).to eq "subscription" }
44
+ it { expect(invoice.description).to eq "Assinatura da aula de desenho" }
45
+
46
+ end
47
+
48
+ describe "#update" do
49
+ let(:update_params) do
50
+ {
51
+ orderExternalId: "ORD-NLQ916TW81TN",
52
+ customerExternalId: "CUS-GF45QI98NST1"
53
+ }
54
+ end
55
+
56
+ let(:updated_invoice) do
57
+ VCR.use_cassette("update_invoice") do
58
+ invoice_api.update invoice_external_id, update_params
59
+ end
60
+ end
61
+
62
+ it { expect(updated_invoice.id).to eq "INV-4517A209DDA9" }
63
+
64
+ it { expect(updated_invoice.order_external_id).to eq "ORD-NLQ916TW81TN" }
65
+ it { expect(updated_invoice.customer_external_id).to eq "CUS-GF45QI98NST1" }
66
+
67
+ it { expect(updated_invoice.email).to eq "caio.gama@moip.com.br" }
68
+ it { expect(updated_invoice.type).to eq "subscription" }
69
+ it { expect(updated_invoice.description).to eq "Assinatura da aula de desenho" }
70
+
71
+ end
72
+
73
+ describe "#list" do
74
+ let (:result) do
75
+ VCR.use_cassette("list_invoices") do
76
+ invoice_api.list begin_date, end_date
77
+ end
78
+ end
79
+
80
+ context "request with results" do
81
+
82
+ let(:begin_date) { '2015-01-01' }
83
+ let(:end_date) { '2015-03-31' }
84
+
85
+ it { expect(result).to_not be_nil }
86
+ it { expect(result.invoices.size).to eq 2 }
87
+ it { expect(result.invoices[0].id).to eq 'INV-635DC2BB9422' }
88
+ it { expect(result.invoices[0].account_id).to eq 'MPA-MAROTO000000' }
89
+ it { expect(result.invoices[1].id).to eq 'INV-635DC2BSHJ90' }
90
+ it { expect(result.invoices[1].account_id).to eq 'MPA-MAROTO000000' }
91
+ end
92
+
93
+ end
94
+
95
+ end
@@ -0,0 +1,19 @@
1
+ describe Moip2::KeysApi do
2
+ let(:keys_api) { described_class.new sandbox_oauth_client }
3
+
4
+ describe "#show" do
5
+
6
+ let(:keys) do
7
+ VCR.use_cassette("get_keys") do
8
+ keys_api.show
9
+ end
10
+ end
11
+
12
+ context 'when shooting request' do
13
+ it { expect(keys).not_to be_nil }
14
+ it { expect(keys.keys.basic_auth.secret).to eq "ABABABABABABABABABABABABABABABABABABABAB" }
15
+ it { expect(keys.keys.basic_auth.token).to eq "01010101010101010101010101010101"}
16
+ end
17
+ end
18
+
19
+ end