paid 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d1bce0b8dfa8caf72176df4abcdfd7be9b30262
4
- data.tar.gz: 1000696410a8767e4389df95c9e0caa93b8b9e41
3
+ metadata.gz: 6062c2c505109c0f6ba17a37be0987381587a8bf
4
+ data.tar.gz: 7aaab841f57542a5340fe66cd62c1073a6c34727
5
5
  SHA512:
6
- metadata.gz: 16e2274c632fc723c6302c2a61c90e3be32dfdbb0279761c404cc72c76058099c1ce6a45c201b207025c953bfda16e8458716a57c33378d5528cb5731f1f974d
7
- data.tar.gz: 6a1eac1770128a35eee7602396a33f2466bba79e3442390b302f6817582767eaea24de8045dff5278df111493637ee1115ff81cd9e9a30f1555415ca5e911fb8
6
+ metadata.gz: 6349aae78e7450501f501f3cb7ec54293fd24e82179cd843c7fbdffb8bc3ee7cce721471051bdfa412462e8892ddb2cfc475a0af31a1b328f2de1be0e90fac18
7
+ data.tar.gz: 0dd7773d9b5fa24bb025f396196cc2f000454e3edb202395849f0a194b76674006e20a1c7eb9318ec3a61832728ca0e200289f8267f489b7b4134e66ac99dfd3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paid (0.0.3)
4
+ paid (0.0.4)
5
5
  json (~> 1.8.1)
6
6
  mime-types (>= 1.25, < 3.0)
7
7
  rest-client (~> 1.4)
@@ -4,7 +4,7 @@ module Paid
4
4
  module ClassMethods
5
5
  def create(params={}, opts={})
6
6
  api_key, headers = Util.parse_opts(opts)
7
- response, api_key = Paid.request(:post, self.url, api_key, params, headers)
7
+ response, api_key = Paid.request(:post, self.api_url, api_key, params, headers)
8
8
  Util.convert_to_paid_object(response, api_key)
9
9
  end
10
10
  end
@@ -3,7 +3,7 @@ module Paid
3
3
  module Delete
4
4
  def delete(params = {}, opts={})
5
5
  api_key, headers = Util.parse_opts(opts)
6
- response, api_key = Paid.request(:delete, url, api_key || @api_key, params, headers)
6
+ response, api_key = Paid.request(:delete, api_url, api_key || @api_key, params, headers)
7
7
  refresh_from(response, api_key)
8
8
  end
9
9
  end
@@ -4,7 +4,7 @@ module Paid
4
4
  module ClassMethods
5
5
  def all(filters={}, opts={})
6
6
  api_key, headers = Util.parse_opts(opts)
7
- response, api_key = Paid.request(:get, url, api_key, filters, headers)
7
+ response, api_key = Paid.request(:get, api_url, api_key, filters, headers)
8
8
  Util.convert_to_paid_object(response, api_key)
9
9
  end
10
10
  end
@@ -11,7 +11,7 @@ module Paid
11
11
  if values.length > 0
12
12
  values.delete(:id)
13
13
 
14
- response, api_key = Paid.request(:post, url, @api_key, values)
14
+ response, api_key = Paid.request(:post, api_url, @api_key, values)
15
15
  refresh_from(response, api_key)
16
16
  end
17
17
  self
@@ -4,7 +4,7 @@ module Paid
4
4
  self.name.split('::')[-1]
5
5
  end
6
6
 
7
- def self.url
7
+ def self.api_url
8
8
  if self == APIResource
9
9
  raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Transaction, Customer, etc.)')
10
10
  end
@@ -12,15 +12,15 @@ module Paid
12
12
  "/v0/#{CGI.escape(class_name.downcase).pluralize}"
13
13
  end
14
14
 
15
- def url
15
+ def api_url
16
16
  unless id = self['id']
17
17
  raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", 'id')
18
18
  end
19
- "#{self.class.url}/#{CGI.escape(id)}"
19
+ "#{self.class.api_url}/#{CGI.escape(id)}"
20
20
  end
21
21
 
22
22
  def refresh
23
- response, api_key = Paid.request(:get, url, @api_key, @retrieve_options)
23
+ response, api_key = Paid.request(:get, api_url, @api_key, @retrieve_options)
24
24
  refresh_from(response, api_key)
25
25
  end
26
26
 
data/lib/paid/customer.rb CHANGED
@@ -25,7 +25,7 @@ module Paid
25
25
  private
26
26
 
27
27
  def generate_invoice_url
28
- url + '/generate_invoice'
28
+ api_url + '/generate_invoice'
29
29
  end
30
30
  end
31
31
  end
data/lib/paid/invoice.rb CHANGED
@@ -11,10 +11,21 @@ module Paid
11
11
  refresh_from(response, api_key)
12
12
  end
13
13
 
14
+ def mark_as_paid(params={}, opts={})
15
+ api_key, headers = Util.parse_opts(opts)
16
+ response, api_key = Paid.request(
17
+ :post, mark_as_paid_url, api_key || @api_key, params, headers)
18
+ refresh_from(response, api_key)
19
+ end
20
+
14
21
  private
15
22
 
16
23
  def issue_url
17
- url + '/issue'
24
+ api_url + '/issue'
25
+ end
26
+
27
+ def mark_as_paid_url
28
+ api_url + '/mark_as_paid'
18
29
  end
19
30
  end
20
31
  end
@@ -1,14 +1,14 @@
1
1
  module Paid
2
2
  class SingletonAPIResource < APIResource
3
- def self.url
3
+ def self.api_url
4
4
  if self == SingletonAPIResource
5
5
  raise NotImplementedError.new('SingletonAPIResource is an abstract class. You should perform actions on its subclasses (Account, etc.)')
6
6
  end
7
7
  "/v0/#{CGI.escape(class_name.downcase)}"
8
8
  end
9
9
 
10
- def url
11
- self.class.url
10
+ def api_url
11
+ self.class.api_url
12
12
  end
13
13
 
14
14
  def self.retrieve(api_key=nil)
data/lib/paid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Paid
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
Binary file
@@ -16,10 +16,18 @@ module Paid
16
16
 
17
17
  should "charges should be issuable" do
18
18
  @mock.expects(:get).never
19
- @mock.expects(:post).once.returns(test_response({:id => "ch_test_charge", :issued_at => 123467890}))
20
- i = Paid::Invoice.new("test_charge")
19
+ @mock.expects(:post).once.returns(test_response({:id => "inv_test_invoice", :issued_at => 123467890}))
20
+ i = Paid::Invoice.new("test_invoice")
21
21
  i.issue
22
22
  assert !i.issued_at.nil?
23
23
  end
24
+
25
+ should "charges should be able to be marked as paid" do
26
+ @mock.expects(:get).never
27
+ @mock.expects(:post).once.returns(test_response({:id => "inv_test_invoice", :paid => true}))
28
+ i = Paid::Invoice.new("test_invoice")
29
+ i.mark_as_paid
30
+ assert i.paid
31
+ end
24
32
  end
25
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Jackson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -155,6 +155,7 @@ files:
155
155
  - paid.gemspec
156
156
  - pkg/paid-0.0.1.gem
157
157
  - pkg/paid-0.0.2.gem
158
+ - pkg/paid-0.0.3.gem
158
159
  - test/paid/account_test.rb
159
160
  - test/paid/alias_test.rb
160
161
  - test/paid/api_resource_test.rb