moip-assinaturas 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/lib/moip-assinaturas/client.rb +5 -0
- data/lib/moip-assinaturas/subscription.rb +19 -0
- data/lib/moip-assinaturas/version.rb +1 -1
- data/spec/moip-assinaturas/subscription_spec.rb +29 -0
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
M2ZkZWIwNGQ5Y2UyOTY5ZTlmYjM1MDYwMDcwMWI3YTJlYTgwZDJkYw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5cc9c89ac4d6f6bb06e6e1d307853e24d167bf96
|
4
|
+
data.tar.gz: 4b0a4a6915f56ec057fb30968ddbe4f4b22d810f
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MDg3YjI0MzQ3YTI1NTE5ZjM0NTVhMDZhZjE0YjcyZGJlNDFhMWIzYmRkMmM2
|
11
|
-
YTk4ZmEzMDQ2MDFmNDYyZDc0ZjJmNWYyNjUzMTFhOTM4OTI0MGU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjVjNjIwNjhkMjMxMjE2YzMwODg0YWY5ZTFjMDk4OTY3NjIyZTdiNjIzM2Ew
|
14
|
-
ZDkwNWU1YTY4YTFmYTlkYjZkOTIxYWZhZDU3ZjUxMzI4ZDZiZmQwNzBiMTRi
|
15
|
-
M2JjODAwN2E1Y2UxYjViNTFiYzA3ODkyZWExZjlmODVjOTk5MGQ=
|
6
|
+
metadata.gz: 2c7f5a1bd924cba308d690cccd4b970907940afaa5562b6d0e2350cc9172c12b53ef505aa21a3d98eb0e0f521b4312fdfc5fba08fa511f2aa4c18f869c2daecf
|
7
|
+
data.tar.gz: fe7104fc1a3185b14976d994d7269094c4f910405f5b8a044816c0c1f872857bb601edea5454f0c0d8b51f653aacf444f3a02913788c862738c75385a5b75481
|
@@ -91,6 +91,11 @@ module Moip::Assinaturas
|
|
91
91
|
peform_action!(:put, "/subscriptions/#{code}/activate", opts, true)
|
92
92
|
end
|
93
93
|
|
94
|
+
def cancel_subscription(code, opts={})
|
95
|
+
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
96
|
+
peform_action!(:put, "/subscriptions/#{code}/cancel", opts, true)
|
97
|
+
end
|
98
|
+
|
94
99
|
def list_invoices(subscription_code, opts={})
|
95
100
|
prepare_options(opts, { headers: { 'Content-Type' => 'application/json' } })
|
96
101
|
peform_action!(:get, "/subscriptions/#{subscription_code}/invoices", opts)
|
@@ -115,6 +115,25 @@ module Moip::Assinaturas
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def cancel(code, opts={})
|
119
|
+
response = Moip::Assinaturas::Client.cancel_subscription(code, opts)
|
120
|
+
hash = JSON.load(response.body)
|
121
|
+
hash = hash ? hash.with_indifferent_access : {}
|
122
|
+
|
123
|
+
case response.code
|
124
|
+
when 200
|
125
|
+
return { success: true }
|
126
|
+
when 400
|
127
|
+
return {
|
128
|
+
success: false,
|
129
|
+
message: hash[:message],
|
130
|
+
errors: hash[:errors]
|
131
|
+
}
|
132
|
+
else
|
133
|
+
raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
118
137
|
end
|
119
138
|
|
120
139
|
end
|
@@ -68,6 +68,13 @@ describe Moip::Assinaturas::Subscription do
|
|
68
68
|
status: [200, 'OK']
|
69
69
|
)
|
70
70
|
|
71
|
+
FakeWeb.register_uri(
|
72
|
+
:put,
|
73
|
+
"https://TOKEN:KEY@api.moip.com.br/assinaturas/v1/subscriptions/assinatura1/cancel",
|
74
|
+
body: '',
|
75
|
+
status: [200, 'OK']
|
76
|
+
)
|
77
|
+
|
71
78
|
FakeWeb.register_uri(
|
72
79
|
:post,
|
73
80
|
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions?new_customer=false",
|
@@ -110,6 +117,13 @@ describe Moip::Assinaturas::Subscription do
|
|
110
117
|
body: '',
|
111
118
|
status: [200, 'OK']
|
112
119
|
)
|
120
|
+
|
121
|
+
FakeWeb.register_uri(
|
122
|
+
:put,
|
123
|
+
"https://TOKEN2:KEY2@api.moip.com.br/assinaturas/v1/subscriptions/assinatura2/cancel",
|
124
|
+
body: '',
|
125
|
+
status: [200, 'OK']
|
126
|
+
)
|
113
127
|
end
|
114
128
|
|
115
129
|
it "should create a new subscription" do
|
@@ -145,6 +159,16 @@ describe Moip::Assinaturas::Subscription do
|
|
145
159
|
request[:success].should be_true
|
146
160
|
end
|
147
161
|
|
162
|
+
it "should suspend a subscription" do
|
163
|
+
request = Moip::Assinaturas::Subscription.suspend('assinatura1')
|
164
|
+
request[:success].should be_true
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should cancel a subscription" do
|
168
|
+
request = Moip::Assinaturas::Subscription.cancel('assinatura1')
|
169
|
+
request[:success].should be_true
|
170
|
+
end
|
171
|
+
|
148
172
|
context "Trial" do
|
149
173
|
it "should get the subscription details with trial" do
|
150
174
|
request = Moip::Assinaturas::Subscription.details('assinatura1')
|
@@ -180,6 +204,11 @@ describe Moip::Assinaturas::Subscription do
|
|
180
204
|
request = Moip::Assinaturas::Subscription.activate('assinatura2', moip_auth: $custom_moip_auth)
|
181
205
|
request[:success].should be_true
|
182
206
|
end
|
207
|
+
|
208
|
+
it "should cancel a subscription from a custom moip account" do
|
209
|
+
request = Moip::Assinaturas::Subscription.cancel('assinatura2', moip_auth: $custom_moip_auth)
|
210
|
+
request[:success].should be_true
|
211
|
+
end
|
183
212
|
end
|
184
213
|
|
185
214
|
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.3.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-05-
|
11
|
+
date: 2014-05-30 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
|
-
- .gitignore
|
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: []
|