api-moip-assinaturas 0.2.32 → 0.2.43

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjA1NjU2OTYyZWUzYmVmZTM4NjMxY2QzOWNmMGYwYWI0OWYwZTUzYQ==
4
+ ZDNmNWI0MjU5ZDBhNWFmYmRmNjExZDVhZGIxMjAzYjY1NzJjNWVjMA==
5
5
  data.tar.gz: !binary |-
6
- NDk3ZjM3ZTAzZjRiZDNkMjU4YThmMGNkMzAwYmE2MTIyNDA0ZTBmMA==
6
+ ODE3ZjFmYjk1NDI3YzEyZTkzZTk4ZmZkNTc1ZGQxMTI4YmYzZjNkMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MWVkMDg4NTQzNjY5M2ZkYjgyNzNmYjExNDMyYjA3ODU3M2IxNjIxOTgzYTcx
10
- YzFkZjVmNjlhMTFhNTQ4MGJhYjBhOThjNDA2MTYxZWJkYWNmMDNjNjUzZmZj
11
- NDFkNDVjZTQzNzVkZmE1ZGY4OWI0MjJmM2UyOTY3NTc5YmE2ZmE=
9
+ Y2JmYWNmMGFlYjc5MWMwNzQ2YWNmYWY4ZjhmNWU3YjMxYWUxMGUxMmVjYmNl
10
+ OWQ0OGI2ZWE1MzI5NmE1NjA4ZTY1ZGY3YmQwZTNjMjQ2MjU5ZjA0MTcxYzJh
11
+ NWMyOTE3ZjE5NDU1NzY1ODlkNjFhNjhiYTIwYzI2MDVjOWE3Yzg=
12
12
  data.tar.gz: !binary |-
13
- ZjljOGNhZWY4YzcxMTc5NmUwYWRjNjIzMmE5MjUwOTg3MjExZmIwNTdiMDEz
14
- YWM1NDc2MTAxN2RkZjM4MzliODZiZjhmZGM2NDRjOTdmOWQyOTcxYjJhNDlj
15
- YjQ4NmE4NDViOWVkMTgyM2I4Y2IzZjFiMjc1NWEzN2Y0YWYyM2I=
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.32'
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"
@@ -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, "[#{error["code"]}] #{error["description"]}"
21
+ self.errors.add :moip_error, "#{error["description"]}"
22
22
  false
23
23
  else
24
24
  true
@@ -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, :invoices
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 = self.load
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
@@ -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
@@ -45,7 +45,7 @@ class Moip::Plan < Moip::Model
45
45
  def plans= hash
46
46
  @plans = []
47
47
  hash.each do |e|
48
- plan = Moip::Plan.new
48
+ plan = self.class.new
49
49
  plan.set_parameters e
50
50
  @plans << plan
51
51
  end
@@ -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
- if self.status != "suspend"
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
- if self.status != "activate"
98
- self.status = "activate"
99
- self.class.put(base_url(:subscriptions, :code => self.code, :status => "activate"), default_header).parsed_response
100
- true
101
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-moip-assinaturas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.32
4
+ version: 0.2.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Rossignolli