cameroncox-mousetrap 0.5.3.3 → 0.5.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3.3
1
+ 0.5.3.4
@@ -0,0 +1,34 @@
1
+ module Mousetrap
2
+ class Invoice < Resource
3
+ attr_accessor \
4
+ :id,
5
+ :number,
6
+ :billing_date,
7
+ :created_at
8
+
9
+ protected
10
+
11
+ def self.plural_resource_name
12
+ 'invoices'
13
+ end
14
+
15
+ def self.singular_resource_name
16
+ 'invoice'
17
+ end
18
+
19
+ attr_writer \
20
+ :id,
21
+ :number,
22
+ :billing_date,
23
+ :created_at
24
+
25
+ def self.attributes_from_api(attributes)
26
+ {
27
+ :id => attributes['id'],
28
+ :number => attributes['number'],
29
+ :billing_date => attributes['billingDatetime'],
30
+ :created_at => attributes['createdDatetime']
31
+ }
32
+ end
33
+ end
34
+ end
@@ -6,6 +6,7 @@ module Mousetrap
6
6
  :items,
7
7
  :recurring_charge_amount
8
8
 
9
+
9
10
  def self.all
10
11
  response = get_resources plural_resource_name
11
12
  return [] unless response['plans']
@@ -10,7 +10,6 @@ module Mousetrap
10
10
  :credit_card_expiration_year,
11
11
  :billing_zip_code,
12
12
  :plan,
13
-
14
13
  :customer_code # belongs to customer
15
14
 
16
15
  # Attributes that come _from_ the API.
@@ -21,7 +20,8 @@ module Mousetrap
21
20
  :credit_card_expiration_date,
22
21
  :credit_card_last_four_digits,
23
22
  :credit_card_type,
24
- :items
23
+ :items,
24
+ :invoices
25
25
 
26
26
  def self.[](code)
27
27
  raise_api_unsupported_error
@@ -52,6 +52,23 @@ module Mousetrap
52
52
  }
53
53
  end
54
54
 
55
+ def current_invoice
56
+ invoice_record = if invoices.kind_of?(Array)
57
+ invoices['invoice'].first
58
+ else
59
+ invoices['invoice']
60
+ end
61
+
62
+ attributes = {
63
+ :id => invoice_record['id'],
64
+ :number => invoice_record['number'],
65
+ :created_at => invoice_record['createdDatetime'],
66
+ :billing_date => invoice_record['billingDatetime']
67
+ }
68
+
69
+ Invoice.new(attributes)
70
+ end
71
+
55
72
  def attributes_for_api
56
73
  self.class.attributes_for_api(attributes)
57
74
  end
@@ -95,7 +112,8 @@ module Mousetrap
95
112
  :credit_card_expiration_date,
96
113
  :credit_card_last_four_digits,
97
114
  :credit_card_type,
98
- :items
115
+ :items,
116
+ :invoices
99
117
 
100
118
  def self.plural_resource_name
101
119
  'subscriptions'
@@ -113,7 +131,7 @@ module Mousetrap
113
131
  :ccNumber => attributes[:credit_card_number],
114
132
  :ccExpMonth => ("%02d" % attributes[:credit_card_expiration_month] if attributes[:credit_card_expiration_month]),
115
133
  :ccExpYear => attributes[:credit_card_expiration_year],
116
- :ccZip => attributes[:billing_zip_code],
134
+ :ccZip => attributes[:billing_zip_code]
117
135
  }
118
136
  end
119
137
 
@@ -125,7 +143,8 @@ module Mousetrap
125
143
  :credit_card_expiration_date => attributes['ccExpirationDate'],
126
144
  :credit_card_last_four_digits => attributes['ccLastFour'],
127
145
  :credit_card_type => attributes['ccType'],
128
- :items => attributes['items']
146
+ :items => attributes['items'],
147
+ :invoices => attributes['invoices']
129
148
  }
130
149
  end
131
150
  end
data/lib/mousetrap.rb CHANGED
@@ -10,6 +10,7 @@ module Mousetrap
10
10
  autoload :Plan, 'mousetrap/plan'
11
11
  autoload :Resource, 'mousetrap/resource'
12
12
  autoload :Subscription, 'mousetrap/subscription'
13
+ autoload :Invoice, 'mousetrap/invoice'
13
14
 
14
15
  class << self
15
16
  attr_accessor :product_code
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cameroncox-mousetrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3.3
4
+ version: 0.5.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Larkowski
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-11-19 00:00:00 -05:00
15
+ date: 2010-01-18 00:00:00 -05:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -72,6 +72,7 @@ files:
72
72
  - VERSION
73
73
  - lib/mousetrap.rb
74
74
  - lib/mousetrap/customer.rb
75
+ - lib/mousetrap/invoice.rb
75
76
  - lib/mousetrap/plan.rb
76
77
  - lib/mousetrap/resource.rb
77
78
  - lib/mousetrap/subscription.rb