api-moip-assinaturas 0.2.22 → 0.2.24
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 +8 -8
- data/api_moip_assinaturas.gemspec +1 -1
- data/lib/moip/model.rb +10 -0
- data/lib/moip/models/customer.rb +3 -2
- data/lib/moip/models/plan.rb +4 -3
- data/lib/moip/models/subscription.rb +13 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjAzNDhjM2NjZTVlZjg5MzZkMGEzMmQzZDZjYzFlZDQ2Y2Y3MTE0Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzlkZjc3ODY4ZTU1NzkxMTA0ZDZhNzU4ODNhMzI2NTFmZWNlZWY4Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDM1OGM3MjVlZjFlZWJhODEzZmFjNDA5OTc5MGRiYzYzOGY0Y2E3ZDBjZmVj
|
10
|
+
Mzk2ZGQ4OGZmNWJkMzc4NjZjMjlkYWFjMWVkZWM3MjE5ODNiMjA0NTcyYjk2
|
11
|
+
ZGY1ZTVmMjg4NDllY2YyNzI5NjI0MDdhODU4Y2NlYWU1M2ZlODc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2RjM2RkN2NmNTVhMmE0NTQxNmFhN2E3MzkzOTJkYTkwMWY4ZGNiNzQ4NjY1
|
14
|
+
ZjczNmY0ZDMxNzM4NjViZDI5OGI2OWFiYTM5NjYzMDU2OGMzMTdiNGEyYjg2
|
15
|
+
MzFiODJhODljMTA5NDcwZDYzZjJiNGYxZjRiOGQwZWYzM2VhMzQ=
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'api-moip-assinaturas'
|
6
|
-
s.version = '0.2.
|
6
|
+
s.version = '0.2.24'
|
7
7
|
s.date = '2013-07-02'
|
8
8
|
s.summary = "Moip Assinaturas by Pixxel"
|
9
9
|
s.description = "Gem desenvolvida para atender aos requisitos do moip api de assinaturas"
|
data/lib/moip/model.rb
CHANGED
@@ -15,6 +15,16 @@ module Moip
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def build_error response
|
19
|
+
if response.key? "errors"
|
20
|
+
error = response["errors"][0]
|
21
|
+
self.errors.add :moip_error, "[#{error["code"]}] #{error["description"]}"
|
22
|
+
false
|
23
|
+
else
|
24
|
+
true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
18
28
|
class << self
|
19
29
|
# metodo que cria um objeto e seta os seus parametros se responder pela chave
|
20
30
|
# recebe um Hash como parametro
|
data/lib/moip/models/customer.rb
CHANGED
@@ -102,9 +102,10 @@ class Moip::Customer < Moip::Model
|
|
102
102
|
# see http://moiplabs.github.io/assinaturas-docs/api.html#criar_cliente
|
103
103
|
def create
|
104
104
|
if self.valid?
|
105
|
-
self.class.post(base_url(:customers, :params => "new_vault=true"), default_header(self.to_json)).parsed_response
|
105
|
+
response = self.class.post(base_url(:customers, :params => "new_vault=true"), default_header(self.to_json)).parsed_response
|
106
|
+
self.validate_response response
|
106
107
|
else
|
107
|
-
|
108
|
+
false
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
data/lib/moip/models/plan.rb
CHANGED
@@ -62,9 +62,10 @@ class Moip::Plan < Moip::Model
|
|
62
62
|
# see http://moiplabs.github.io/assinaturas-docs/api.html#criar_plano
|
63
63
|
def create
|
64
64
|
if self.valid?
|
65
|
-
self.class.post(base_url(:plans), default_header(self.to_json)).parsed_response
|
65
|
+
response = self.class.post(base_url(:plans), default_header(self.to_json)).parsed_response
|
66
|
+
self.validate_response response
|
66
67
|
else
|
67
|
-
|
68
|
+
false
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -80,7 +81,7 @@ class Moip::Plan < Moip::Model
|
|
80
81
|
self.class.put(base_url(:plans, :code => self.code), default_header(self)).parsed_response
|
81
82
|
true
|
82
83
|
else
|
83
|
-
|
84
|
+
false
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
@@ -5,7 +5,7 @@ class Moip::Subscription < Moip::Model
|
|
5
5
|
|
6
6
|
attr_accessor :code, :amount, :plan, :customer,
|
7
7
|
:next_invoice_date, :status, :message,
|
8
|
-
:
|
8
|
+
:invoice, :creation_date,
|
9
9
|
:expiration_date, :subscriptions
|
10
10
|
|
11
11
|
validates :code, :amount, :plan, :customer, :presence => true
|
@@ -23,7 +23,9 @@ class Moip::Subscription < Moip::Model
|
|
23
23
|
if @plan.is_a? Hash
|
24
24
|
@plan
|
25
25
|
else
|
26
|
-
|
26
|
+
return nil if @plan.nil?
|
27
|
+
@plan = { :code => @plan }
|
28
|
+
@plan
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -31,7 +33,9 @@ class Moip::Subscription < Moip::Model
|
|
31
33
|
if @customer.is_a? Hash
|
32
34
|
@customer
|
33
35
|
else
|
34
|
-
|
36
|
+
return nil if @customer.nil?
|
37
|
+
@customer ={ :code => @customer }
|
38
|
+
@customer
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
@@ -61,7 +65,12 @@ class Moip::Subscription < Moip::Model
|
|
61
65
|
|
62
66
|
# see http://moiplabs.github.io/assinaturas-docs/api.html#criar_assinatura
|
63
67
|
def create
|
64
|
-
|
68
|
+
if self.valid?
|
69
|
+
response = self.class.post(base_url(:subscriptions), default_header(self.to_json)).parsed_response
|
70
|
+
self.validate_response response
|
71
|
+
else
|
72
|
+
false
|
73
|
+
end
|
65
74
|
end
|
66
75
|
|
67
76
|
# To Do
|