api-moip-assinaturas 0.2.32 → 0.2.43
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 +1 -1
- data/lib/moip/models/invoice.rb +11 -3
- data/lib/moip/models/payment.rb +0 -8
- data/lib/moip/models/plan.rb +1 -1
- data/lib/moip/models/subscription.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDNmNWI0MjU5ZDBhNWFmYmRmNjExZDVhZGIxMjAzYjY1NzJjNWVjMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODE3ZjFmYjk1NDI3YzEyZTkzZTk4ZmZkNTc1ZGQxMTI4YmYzZjNkMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2JmYWNmMGFlYjc5MWMwNzQ2YWNmYWY4ZjhmNWU3YjMxYWUxMGUxMmVjYmNl
|
10
|
+
OWQ0OGI2ZWE1MzI5NmE1NjA4ZTY1ZGY3YmQwZTNjMjQ2MjU5ZjA0MTcxYzJh
|
11
|
+
NWMyOTE3ZjE5NDU1NzY1ODlkNjFhNjhiYTIwYzI2MDVjOWE3Yzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjkzM2RiZGMxYzgwZjUyMGU0MGQwMTc4ZmI4ZTMxZmEyZWJjMGU1NjcwMjRj
|
14
|
+
OGU4OTJmMDQxMjhmNTY4Y2M4OWE2ZmFkMDY4ODcwNmE0MjZmMDFhN2I3ZTlk
|
15
|
+
NzFjMTE3Zjk3ODAyMmEwMWJmNzNlNzQ3ZGFkMmQ2ODYwZTA2NDg=
|
@@ -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.43'
|
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
@@ -18,7 +18,7 @@ module Moip
|
|
18
18
|
def validate_response response
|
19
19
|
if response.key? "errors" and response["errors"].size > 0
|
20
20
|
error = response["errors"][0]
|
21
|
-
self.errors.add :moip_error, "
|
21
|
+
self.errors.add :moip_error, "#{error["description"]}"
|
22
22
|
false
|
23
23
|
else
|
24
24
|
true
|
data/lib/moip/models/invoice.rb
CHANGED
@@ -4,7 +4,7 @@ class Moip::Invoice < Moip::Model
|
|
4
4
|
include Moip::Header
|
5
5
|
|
6
6
|
attr_accessor :id, :amount, :subscription_code, :occurrence,
|
7
|
-
:status, :items, :plan, :customer, :creation_date
|
7
|
+
:status, :items, :plan, :customer, :creation_date
|
8
8
|
|
9
9
|
def attributes
|
10
10
|
{
|
@@ -31,7 +31,7 @@ class Moip::Invoice < Moip::Model
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def full_status
|
34
|
-
status = case self.status
|
34
|
+
status = case self.status['code']
|
35
35
|
when 1 then "Em aberto" # A fatura foi gerada mas ainda não foi paga pelo assinante.
|
36
36
|
when 2 then "Aguardando Confirmação" # A fatura foi paga pelo assinante, mas o pagamento está em processo de análise de risco.
|
37
37
|
when 3 then "Pago" # A fatura foi paga pelo assinante e confirmada.
|
@@ -42,7 +42,7 @@ class Moip::Invoice < Moip::Model
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def invoices
|
45
|
-
@invoices ||= self.invoices
|
45
|
+
@invoices ||= self.invoices=(self.load)
|
46
46
|
end
|
47
47
|
|
48
48
|
def load
|
@@ -58,5 +58,13 @@ class Moip::Invoice < Moip::Model
|
|
58
58
|
def payments
|
59
59
|
@payments ||= Moip::Payment.build(:invoice => self.id).payments
|
60
60
|
end
|
61
|
+
|
62
|
+
def retry
|
63
|
+
response = self.class.post(base_url(:invoices, :code => self.id, :status => "retry"), default_header).parsed_response
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.retry id
|
67
|
+
response = self.class.post(base_url(:payments, :code => id, :status => "retry"), default_header).parsed_response
|
68
|
+
end
|
61
69
|
|
62
70
|
end
|
data/lib/moip/models/payment.rb
CHANGED
@@ -42,13 +42,5 @@ class Moip::Payment < Moip::Model
|
|
42
42
|
response = self.class.get(base_url(:payments, :code => self.id), default_header).parsed_response
|
43
43
|
self.set_parameters response unless response.nil?
|
44
44
|
end
|
45
|
-
|
46
|
-
def retry
|
47
|
-
response = self.class.get(base_url(:payments, :code => self.id, :status => "retry"), default_header).parsed_response
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.retry id
|
51
|
-
response = self.class.get(base_url(:payments, :code => id, :status => "retry"), default_header).parsed_response
|
52
|
-
end
|
53
45
|
|
54
46
|
end
|
data/lib/moip/models/plan.rb
CHANGED
@@ -19,6 +19,10 @@ class Moip::Subscription < Moip::Model
|
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
22
|
+
def active?
|
23
|
+
self.satus == "ACTIVE"
|
24
|
+
end
|
25
|
+
|
22
26
|
def plan
|
23
27
|
if @plan.is_a? Hash
|
24
28
|
@plan
|
@@ -86,19 +90,15 @@ class Moip::Subscription < Moip::Model
|
|
86
90
|
end
|
87
91
|
|
88
92
|
def suspend
|
89
|
-
|
90
|
-
self.status = "suspend"
|
91
|
-
self.class.put(base_url(:subscriptions, :code => self.code, :status => "suspend"), default_header).parsed_response
|
92
|
-
true
|
93
|
-
end
|
93
|
+
self.class.put(base_url(:subscriptions, :code => self.code, :status => "suspend"), default_header({}.to_json)).parsed_response
|
94
94
|
end
|
95
95
|
|
96
96
|
def activate
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
self.class.put(base_url(:subscriptions, :code => self.code, :status => "activate"), default_header({}.to_json)).parsed_response
|
98
|
+
end
|
99
|
+
|
100
|
+
def cancel
|
101
|
+
self.class.put(base_url(:subscriptions, :code => self.code, :status => "cancel"), default_header({}.to_json)).parsed_response
|
102
102
|
end
|
103
103
|
|
104
104
|
# see http://moiplabs.github.io/assinaturas-docs/api.html#alterar_assinatura
|