api-moip-assinaturas 0.2.15 → 0.2.16

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzAxZmVmZTIzMjA5OGY3OTFiOTYxMjcyODhlZTk4ZjY1YjQyOTQ1NA==
4
+ ODgwY2ExOGVmYjM1NzY3YjIxMWVjODAwZWEzMjRiZjkwODgwZjAzZQ==
5
5
  data.tar.gz: !binary |-
6
- ZDBlODE1NTg0MTA0NDc5MTAyZTc0YTY3NTVlZGE0ZGY4ODlmMzgwNA==
6
+ MTU0NWMxZjIxY2U4OWZiZGM1MmYwYzY4ZjUwMDQ0N2JkNGY2MGU4Yw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjViMjhjZTA5YzZkOTdkYzQ1NWVmYjNlNDg1ZjIxOTdjNDQ0NzBjZTlkNmI5
10
- ZTdmNmY1MDA5MWQwNTZhNjM3ODc1ZTYwN2M5NWM5MGI3OTkyM2U2MTY3ZTI4
11
- Y2E0N2ZiNDUyMzZkMDQ2NTY0ZDQ5YTU4ZTViZWRhNjNkMTYyOGM=
9
+ NzYzNzZiNDFiOTVmY2E0N2ZiZjk0YmY5OTA5M2ZmOTU4N2Y2ZDJjYzBmMzM5
10
+ NTE5ZTU1OWNkMDBiOWMzMDdhZDlkMTUxMDJmMzBiYzE4MzJmNTI3YzgxM2I0
11
+ MWM5ZTYxMjBiNmYyNGQzZDAzODBjNTMxOWI1YTA5NTc4ZGUwZDA=
12
12
  data.tar.gz: !binary |-
13
- YTdiMzc0MTk2ZjU0OWE1Zjc2MDY2MTBmNDIzYTFiMTcyMmNkMWQwNjhlYjgw
14
- Yzk1NWUzNjU0YzJhYTgwMGIzMmRiZTMxNjM0Y2NlNDAwYzljMjU4NWExY2I3
15
- NDFkYjA3OTQ4ODA0YTllYTgyNmIzMGZkNzc5YmRlNjdkODZiNGY=
13
+ MDA1YzRjMTdiNDM1ZDZlYzhmMzJhMGMwZDI4ZjYwNjBmZWY1OGYwMTlkNjFj
14
+ ZDg2NTg5NzU1ZWM0MDM2OWQ2OTM2MGExOWVkZjA0MDQ5MTNmMzFiOTg0ZDBh
15
+ MGU5ZjYyMzJhNThkNWEyYWFmODE3YjkxZTU0NjJmNTlmMDY2MjE=
@@ -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.15'
6
+ s.version = '0.2.16'
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"
@@ -3,4 +3,7 @@ en:
3
3
  errors:
4
4
  presence_of_address: "can't be blank"
5
5
  presence_of_billing_info: "can't be blank"
6
- invalid_format: "invalid format"
6
+ invalid_format: "invalid format"
7
+ invalid_card_number: "invalid card number"
8
+ invalid_expiration_year: "invalid expiration year"
9
+ invalid_expiration_month: "invalid expiration month"
@@ -4,12 +4,32 @@ class Moip::BillingInfo < Moip::Model
4
4
 
5
5
  validates :holder_name, :number, :expiration_month, :expiration_year, :presence => true
6
6
 
7
- validates_format_of :expiration_month, :with => /[0-9]{2}/
8
- validates_format_of :expiration_year, :with => /[0-9]{2}/
9
- validates_format_of :number, :with => /[0-9]{16}/
10
-
11
- validate :valida_numero_cartao
7
+ validate :valida_numero_cartao, :validates_format_of_number,
8
+ :validates_format_of_expiration_month, :validates_format_of_expiration_year
12
9
 
10
+ def validates_format_of_number
11
+ if self.number.to_s.match /[0-9]{16}/
12
+ true
13
+ else
14
+ self.errors.add :number, I18n.t("moip.errors.invalid_card_number")
15
+ end
16
+ end
17
+
18
+ def validates_format_of_expiration_year
19
+ if self.expiration_year.to_s.match /[0-9]{2}/
20
+ true
21
+ else
22
+ self.errors.add :expiration_year, I18n.t("moip.errors.invalid_expiration_year")
23
+ end
24
+ end
25
+
26
+ def validates_format_of_expiration_month
27
+ if self.expiration_month.to_s.match /[0-9]{2}/
28
+ true
29
+ else
30
+ self.errors.add :expiration_month, I18n.t("moip.errors.invalid_expiration_month")
31
+ end
32
+ end
13
33
 
14
34
  def valida_numero_cartao
15
35
  patterns.each do |pattern|
@@ -34,7 +34,7 @@ class Moip::Customer < Moip::Model
34
34
  if options.is_a? Hash
35
35
  @address = Moip::Address.build options
36
36
  elsif options.is_a? Moip::Address
37
- @address = Moip::Address
37
+ @address = options
38
38
  end
39
39
  end
40
40
 
@@ -46,7 +46,7 @@ class Moip::Customer < Moip::Model
46
46
  if options.is_a? Hash
47
47
  @billing_info = Moip::BillingInfo.build options
48
48
  elsif options.is_a? Moip::BillingInfo
49
- @billing_info = Moip::BillingInfo
49
+ @billing_info = options
50
50
  end
51
51
  end
52
52
 
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.15
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Rossignolli