moip-assinaturas 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/README.md +6 -0
- data/lib/moip-assinaturas/client.rb +5 -5
- data/lib/moip-assinaturas/customer.rb +8 -2
- data/lib/moip-assinaturas/invoice.rb +8 -2
- data/lib/moip-assinaturas/plan.rb +8 -2
- data/lib/moip-assinaturas/subscription.rb +8 -2
- data/lib/moip-assinaturas/version.rb +1 -1
- data/spec/moip-assinaturas/customer_spec.rb +35 -20
- data/spec/moip-assinaturas/invoice_spec.rb +28 -13
- data/spec/moip-assinaturas/plan_spec.rb +35 -20
- data/spec/moip-assinaturas/subscription_spec.rb +20 -5
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDkxOTQxYjg2YzA5MmI5YWYzMDc3OWFlNjYzNTM5M2Q5ODdiZjJiMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OTYzNjY1YzczODE3ZWM5MWUzNThlMWM5NTE0ZDBmNTYxNDZiNTY1YQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTY5NmZjZmZjYmM4MTNlZjQyMzdmNzI1NWQ3ZTIyNTRlMmZkZjE3OTNmZDIx
|
10
|
+
ZmU2MTg2MWUyMzc2ZDhkMmI3MGMyNDg5YWM5Y2FjYWNiMjRmYjU4MTdkNDU4
|
11
|
+
ODQ4OTJhNjE0MTgzMjA3OGM1NjBkN2UxMmRmNDM2N2VhM2YxMTA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzNlYmRmYTNhMzllYTJiZThkZDZjZjg0OWU2MTg3NzUwYzI0NjRlOTJiODc1
|
14
|
+
NGY1MGMyNDNkNjRkZGFmZjkxNTAzNWNiNDQ4ODVlNDZlNmE4NGFmZWUyNWFh
|
15
|
+
MDhkMmRlYmNhMWI3MDFlOWRiODBlMzY2N2U4YmRjY2I1M2U3OGM=
|
data/README.md
CHANGED
@@ -155,6 +155,12 @@ Ativar uma assinatura:
|
|
155
155
|
Moip::Assinaturas::Subscription.activate(subscription_code)
|
156
156
|
```
|
157
157
|
|
158
|
+
Cancelar uma assinatura:
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
Moip::Assinaturas::Subscription.cancel(subscription_code)
|
162
|
+
```
|
163
|
+
|
158
164
|
## Faturas
|
159
165
|
|
160
166
|
Listar faturas de uma assinatura:
|
@@ -33,7 +33,7 @@ module Moip::Assinaturas
|
|
33
33
|
|
34
34
|
def details_plan(code, opts={})
|
35
35
|
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
36
|
-
peform_action!(:get, "/plans/#{code}", opts)
|
36
|
+
peform_action!(:get, "/plans/#{code}", opts, true)
|
37
37
|
end
|
38
38
|
|
39
39
|
def update_plan(plan, opts={})
|
@@ -53,7 +53,7 @@ module Moip::Assinaturas
|
|
53
53
|
|
54
54
|
def details_customer(code, opts={})
|
55
55
|
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
56
|
-
peform_action!(:get, "/customers/#{code}", opts)
|
56
|
+
peform_action!(:get, "/customers/#{code}", opts, true)
|
57
57
|
end
|
58
58
|
|
59
59
|
def update_credit_card(customer_code, credit_card, opts={})
|
@@ -78,7 +78,7 @@ module Moip::Assinaturas
|
|
78
78
|
|
79
79
|
def details_subscription(code, opts={})
|
80
80
|
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
81
|
-
peform_action!(:get, "/subscriptions/#{code}", opts)
|
81
|
+
peform_action!(:get, "/subscriptions/#{code}", opts, true)
|
82
82
|
end
|
83
83
|
|
84
84
|
def suspend_subscription(code, opts={})
|
@@ -103,7 +103,7 @@ module Moip::Assinaturas
|
|
103
103
|
|
104
104
|
def details_invoice(id, opts={})
|
105
105
|
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
106
|
-
peform_action!(:get, "/invoices/#{id}", opts)
|
106
|
+
peform_action!(:get, "/invoices/#{id}", opts, true)
|
107
107
|
end
|
108
108
|
|
109
109
|
def list_payments(invoice_id, opts={})
|
@@ -161,4 +161,4 @@ module Moip::Assinaturas
|
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
-
end
|
164
|
+
end
|
@@ -41,7 +41,8 @@ module Moip::Assinaturas
|
|
41
41
|
|
42
42
|
def details(code, opts = {})
|
43
43
|
response = Moip::Assinaturas::Client.details_customer(code, opts)
|
44
|
-
hash = JSON.load(response.body)
|
44
|
+
hash = JSON.load(response.body)
|
45
|
+
hash = hash.with_indifferent_access if hash
|
45
46
|
|
46
47
|
case response.code
|
47
48
|
when 200
|
@@ -49,6 +50,11 @@ module Moip::Assinaturas
|
|
49
50
|
success: true,
|
50
51
|
customer: hash
|
51
52
|
}
|
53
|
+
when 404
|
54
|
+
return {
|
55
|
+
success: false,
|
56
|
+
message: 'not found'
|
57
|
+
}
|
52
58
|
else
|
53
59
|
raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
|
54
60
|
end
|
@@ -78,4 +84,4 @@ module Moip::Assinaturas
|
|
78
84
|
|
79
85
|
end
|
80
86
|
end
|
81
|
-
end
|
87
|
+
end
|
@@ -20,7 +20,8 @@ module Moip::Assinaturas
|
|
20
20
|
|
21
21
|
def details(id, opts={})
|
22
22
|
response = Moip::Assinaturas::Client.details_invoice(id, opts)
|
23
|
-
hash = JSON.load(response.body)
|
23
|
+
hash = JSON.load(response.body)
|
24
|
+
hash = hash.with_indifferent_access if hash
|
24
25
|
|
25
26
|
case response.code
|
26
27
|
when 200
|
@@ -28,6 +29,11 @@ module Moip::Assinaturas
|
|
28
29
|
success: true,
|
29
30
|
invoice: hash
|
30
31
|
}
|
32
|
+
when 404
|
33
|
+
return {
|
34
|
+
success: false,
|
35
|
+
message: 'not found'
|
36
|
+
}
|
31
37
|
else
|
32
38
|
raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
|
33
39
|
end
|
@@ -35,4 +41,4 @@ module Moip::Assinaturas
|
|
35
41
|
|
36
42
|
end
|
37
43
|
end
|
38
|
-
end
|
44
|
+
end
|
@@ -41,7 +41,8 @@ module Moip::Assinaturas
|
|
41
41
|
|
42
42
|
def details(code, opts={})
|
43
43
|
response = Moip::Assinaturas::Client.details_plan(code, opts)
|
44
|
-
hash = JSON.load(response.body)
|
44
|
+
hash = JSON.load(response.body)
|
45
|
+
hash = hash.with_indifferent_access if hash
|
45
46
|
|
46
47
|
case response.code
|
47
48
|
when 200
|
@@ -49,6 +50,11 @@ module Moip::Assinaturas
|
|
49
50
|
success: true,
|
50
51
|
plan: hash
|
51
52
|
}
|
53
|
+
when 404
|
54
|
+
return {
|
55
|
+
success: false,
|
56
|
+
message: 'not found'
|
57
|
+
}
|
52
58
|
else
|
53
59
|
raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
|
54
60
|
end
|
@@ -71,4 +77,4 @@ module Moip::Assinaturas
|
|
71
77
|
|
72
78
|
end
|
73
79
|
end
|
74
|
-
end
|
80
|
+
end
|
@@ -64,7 +64,8 @@ module Moip::Assinaturas
|
|
64
64
|
|
65
65
|
def details(code, opts={})
|
66
66
|
response = Moip::Assinaturas::Client.details_subscription(code, opts)
|
67
|
-
hash = JSON.load(response.body)
|
67
|
+
hash = JSON.load(response.body)
|
68
|
+
hash = hash.with_indifferent_access if hash
|
68
69
|
|
69
70
|
case response.code
|
70
71
|
when 200
|
@@ -72,6 +73,11 @@ module Moip::Assinaturas
|
|
72
73
|
success: true,
|
73
74
|
subscription: hash
|
74
75
|
}
|
76
|
+
when 404
|
77
|
+
return {
|
78
|
+
success: false,
|
79
|
+
message: 'not found'
|
80
|
+
}
|
75
81
|
else
|
76
82
|
raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
|
77
83
|
end
|
@@ -137,4 +143,4 @@ module Moip::Assinaturas
|
|
137
143
|
end
|
138
144
|
|
139
145
|
end
|
140
|
-
end
|
146
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Moip::Assinaturas::Customer do
|
5
|
-
|
5
|
+
|
6
6
|
before(:all) do
|
7
7
|
@customer = {
|
8
8
|
code: "18",
|
@@ -35,56 +35,63 @@ describe Moip::Assinaturas::Customer do
|
|
35
35
|
}
|
36
36
|
|
37
37
|
FakeWeb.register_uri(
|
38
|
-
:post,
|
39
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers?new_vault=true",
|
38
|
+
:post,
|
39
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers?new_vault=true",
|
40
40
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'create_customer.json'),
|
41
41
|
status: [201, 'CREATED']
|
42
42
|
)
|
43
43
|
|
44
44
|
FakeWeb.register_uri(
|
45
|
-
:get,
|
46
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers",
|
45
|
+
:get,
|
46
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers",
|
47
47
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'list_customers.json'),
|
48
48
|
status: [200, 'OK']
|
49
49
|
)
|
50
50
|
|
51
51
|
FakeWeb.register_uri(
|
52
|
-
:get,
|
53
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers/18",
|
52
|
+
:get,
|
53
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers/18",
|
54
54
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'details_customer.json'),
|
55
55
|
status: [200, 'OK']
|
56
56
|
)
|
57
57
|
|
58
58
|
FakeWeb.register_uri(
|
59
|
-
:
|
59
|
+
:get,
|
60
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers/not_found",
|
61
|
+
body: '',
|
62
|
+
status: [404, 'Not found']
|
63
|
+
)
|
64
|
+
|
65
|
+
FakeWeb.register_uri(
|
66
|
+
:put,
|
60
67
|
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/customers/18/billing_infos",
|
61
68
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'update_credit_card.json'),
|
62
69
|
status: [200, 'OK']
|
63
70
|
)
|
64
71
|
|
65
72
|
FakeWeb.register_uri(
|
66
|
-
:post,
|
67
|
-
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers?new_vault=true",
|
73
|
+
:post,
|
74
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers?new_vault=true",
|
68
75
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'create_customer.json'),
|
69
76
|
status: [201, 'CREATED']
|
70
77
|
)
|
71
78
|
|
72
79
|
FakeWeb.register_uri(
|
73
|
-
:get,
|
74
|
-
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers",
|
80
|
+
:get,
|
81
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers",
|
75
82
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'list_customers.json'),
|
76
83
|
status: [200, 'OK']
|
77
84
|
)
|
78
85
|
|
79
86
|
FakeWeb.register_uri(
|
80
|
-
:get,
|
81
|
-
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers/18",
|
87
|
+
:get,
|
88
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers/18",
|
82
89
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'details_customer.json'),
|
83
90
|
status: [200, 'OK']
|
84
91
|
)
|
85
92
|
|
86
93
|
FakeWeb.register_uri(
|
87
|
-
:put,
|
94
|
+
:put,
|
88
95
|
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/customers/19/billing_infos",
|
89
96
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'update_credit_card.json'),
|
90
97
|
status: [200, 'OK']
|
@@ -102,10 +109,18 @@ describe Moip::Assinaturas::Customer do
|
|
102
109
|
request[:customers].size.should == 1
|
103
110
|
end
|
104
111
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
112
|
+
describe 'customer details' do
|
113
|
+
it "should get the customer details" do
|
114
|
+
request = Moip::Assinaturas::Customer.details('18')
|
115
|
+
request[:success].should be_true
|
116
|
+
request[:customer][:code].should == '18'
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should return not found when the customer does not exist" do
|
120
|
+
request = Moip::Assinaturas::Customer.details('not_found')
|
121
|
+
request[:success].should be_false
|
122
|
+
request[:message].should == 'not found'
|
123
|
+
end
|
109
124
|
end
|
110
125
|
|
111
126
|
it "should update the customer card info" do
|
@@ -152,4 +167,4 @@ describe Moip::Assinaturas::Customer do
|
|
152
167
|
request[:success].should be_true
|
153
168
|
end
|
154
169
|
end
|
155
|
-
end
|
170
|
+
end
|
@@ -6,29 +6,36 @@ describe Moip::Assinaturas::Invoice do
|
|
6
6
|
before(:all) do
|
7
7
|
|
8
8
|
FakeWeb.register_uri(
|
9
|
-
:get,
|
10
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/subscriptions/assinatura1/invoices",
|
9
|
+
:get,
|
10
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/subscriptions/assinatura1/invoices",
|
11
11
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'list_invoices.json'),
|
12
12
|
status: [200, 'OK']
|
13
13
|
)
|
14
14
|
|
15
15
|
FakeWeb.register_uri(
|
16
|
-
:get,
|
17
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/invoices/13",
|
16
|
+
:get,
|
17
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/invoices/13",
|
18
18
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'details_invoice.json'),
|
19
19
|
status: [200, 'OK']
|
20
20
|
)
|
21
21
|
|
22
22
|
FakeWeb.register_uri(
|
23
|
-
:get,
|
24
|
-
"https://
|
23
|
+
:get,
|
24
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/invoices/not_found",
|
25
|
+
body: '',
|
26
|
+
status: [404, 'Not found']
|
27
|
+
)
|
28
|
+
|
29
|
+
FakeWeb.register_uri(
|
30
|
+
:get,
|
31
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions/assinatura2/invoices",
|
25
32
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'list_invoices.json'),
|
26
33
|
status: [200, 'OK']
|
27
34
|
)
|
28
35
|
|
29
36
|
FakeWeb.register_uri(
|
30
|
-
:get,
|
31
|
-
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/invoices/14",
|
37
|
+
:get,
|
38
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/invoices/14",
|
32
39
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'details_invoice.json'),
|
33
40
|
status: [200, 'OK']
|
34
41
|
)
|
@@ -40,10 +47,18 @@ describe Moip::Assinaturas::Invoice do
|
|
40
47
|
request[:success].should be_true
|
41
48
|
end
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
describe 'invoice details' do
|
51
|
+
it "should get the invoice details" do
|
52
|
+
request = Moip::Assinaturas::Invoice.details(13)
|
53
|
+
request[:success].should be_true
|
54
|
+
request[:invoice][:id].should == 13
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should return not found when invoice does not exist' do
|
58
|
+
request = Moip::Assinaturas::Invoice.details('not_found')
|
59
|
+
request[:success].should be_false
|
60
|
+
request[:message].should == 'not found'
|
61
|
+
end
|
47
62
|
end
|
48
63
|
|
49
64
|
context "Custom Authentication" do
|
@@ -59,4 +74,4 @@ describe Moip::Assinaturas::Invoice do
|
|
59
74
|
end
|
60
75
|
end
|
61
76
|
|
62
|
-
end
|
77
|
+
end
|
@@ -41,57 +41,64 @@ describe Moip::Assinaturas::Plan do
|
|
41
41
|
}
|
42
42
|
|
43
43
|
FakeWeb.register_uri(
|
44
|
-
:post,
|
45
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans",
|
44
|
+
:post,
|
45
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans",
|
46
46
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'create_plan.json'),
|
47
47
|
status: [201, 'OK']
|
48
48
|
)
|
49
49
|
|
50
50
|
FakeWeb.register_uri(
|
51
|
-
:get,
|
52
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans",
|
51
|
+
:get,
|
52
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans",
|
53
53
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'list_plans.json'),
|
54
54
|
status: [200, 'OK']
|
55
55
|
)
|
56
56
|
|
57
57
|
FakeWeb.register_uri(
|
58
|
-
:get,
|
59
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans/plano01",
|
58
|
+
:get,
|
59
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans/plano01",
|
60
60
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'details_plan.json'),
|
61
61
|
status: [200, 'OK']
|
62
62
|
)
|
63
63
|
|
64
64
|
FakeWeb.register_uri(
|
65
|
-
:
|
66
|
-
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans/
|
65
|
+
:get,
|
66
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans/not_found",
|
67
|
+
body: '',
|
68
|
+
status: [404, 'Not found']
|
69
|
+
)
|
70
|
+
|
71
|
+
FakeWeb.register_uri(
|
72
|
+
:put,
|
73
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/plans/plano01",
|
67
74
|
body: "",
|
68
75
|
status: [200, 'OK']
|
69
76
|
)
|
70
77
|
|
71
78
|
FakeWeb.register_uri(
|
72
|
-
:post,
|
73
|
-
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans",
|
79
|
+
:post,
|
80
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans",
|
74
81
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'create_plan.json'),
|
75
82
|
status: [201, 'OK']
|
76
83
|
)
|
77
84
|
|
78
85
|
FakeWeb.register_uri(
|
79
|
-
:get,
|
80
|
-
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans",
|
86
|
+
:get,
|
87
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans",
|
81
88
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'list_plans.json'),
|
82
89
|
status: [200, 'OK']
|
83
90
|
)
|
84
91
|
|
85
92
|
FakeWeb.register_uri(
|
86
|
-
:get,
|
87
|
-
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans/plano02",
|
93
|
+
:get,
|
94
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans/plano02",
|
88
95
|
body: File.join(File.dirname(__FILE__), '..', 'fixtures', 'custom_authentication', 'details_plan.json'),
|
89
96
|
status: [200, 'OK']
|
90
97
|
)
|
91
98
|
|
92
99
|
FakeWeb.register_uri(
|
93
|
-
:put,
|
94
|
-
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans/plano02",
|
100
|
+
:put,
|
101
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/plans/plano02",
|
95
102
|
body: "",
|
96
103
|
status: [200, 'OK']
|
97
104
|
)
|
@@ -109,10 +116,18 @@ describe Moip::Assinaturas::Plan do
|
|
109
116
|
request[:plans].size.should == 1
|
110
117
|
end
|
111
118
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
119
|
+
describe 'plan details' do
|
120
|
+
it "should get details from a plan" do
|
121
|
+
request = Moip::Assinaturas::Plan.details('plano01')
|
122
|
+
request[:success].should be_true
|
123
|
+
request[:plan][:code].should == 'plano01'
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should return not found when a plan does not exist' do
|
127
|
+
request = Moip::Assinaturas::Plan.details('not_found')
|
128
|
+
request[:success].should be_false
|
129
|
+
request[:message].should == 'not found'
|
130
|
+
end
|
116
131
|
end
|
117
132
|
|
118
133
|
it "should update an existing plan" do
|
@@ -54,6 +54,13 @@ describe Moip::Assinaturas::Subscription do
|
|
54
54
|
status: [200, 'OK']
|
55
55
|
)
|
56
56
|
|
57
|
+
FakeWeb.register_uri(
|
58
|
+
:get,
|
59
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/subscriptions/not_found",
|
60
|
+
body: '',
|
61
|
+
status: [404, 'Not found']
|
62
|
+
)
|
63
|
+
|
57
64
|
FakeWeb.register_uri(
|
58
65
|
:put,
|
59
66
|
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/subscriptions/assinatura1/activate",
|
@@ -143,10 +150,18 @@ describe Moip::Assinaturas::Subscription do
|
|
143
150
|
request[:subscriptions].size.should == 1
|
144
151
|
end
|
145
152
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
153
|
+
describe 'subscription details' do
|
154
|
+
it "should get the subscription details" do
|
155
|
+
request = Moip::Assinaturas::Subscription.details('assinatura1')
|
156
|
+
request[:success].should be_true
|
157
|
+
request[:subscription][:code].should == 'assinatura1'
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should return not found when the subscription does not exist' do
|
161
|
+
request = Moip::Assinaturas::Subscription.details('not_found')
|
162
|
+
request[:success].should be_false
|
163
|
+
request[:message].should == 'not found'
|
164
|
+
end
|
150
165
|
end
|
151
166
|
|
152
167
|
it "should suspend a subscription" do
|
@@ -211,4 +226,4 @@ describe Moip::Assinaturas::Subscription do
|
|
211
226
|
end
|
212
227
|
end
|
213
228
|
|
214
|
-
end
|
229
|
+
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moip-assinaturas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Warlley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.13'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: guard-rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.5.4
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.5.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: growl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.0.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.0.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fakeweb
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.3.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0.9'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.9'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: httparty
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.12.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.12.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: activesupport
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ! '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 2.3.2
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ! '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.3.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: json
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '1.7'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ! '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '1.7'
|
125
125
|
description: Ruby Gem para uso do serviço de assinaturas do Moip
|
@@ -129,7 +129,7 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
-
-
|
132
|
+
- .gitignore
|
133
133
|
- Gemfile
|
134
134
|
- Guardfile
|
135
135
|
- LICENSE.txt
|
@@ -192,12 +192,12 @@ require_paths:
|
|
192
192
|
- lib
|
193
193
|
required_ruby_version: !ruby/object:Gem::Requirement
|
194
194
|
requirements:
|
195
|
-
- -
|
195
|
+
- - ! '>='
|
196
196
|
- !ruby/object:Gem::Version
|
197
197
|
version: '0'
|
198
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- -
|
200
|
+
- - ! '>='
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: '0'
|
203
203
|
requirements: []
|