paid 0.0.1 → 0.0.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acd4fd8d0c3ea2366a13704be64eed1765bc7541
4
- data.tar.gz: 5d7e118d0735f1da69ad6d04d315e455953e44f0
3
+ metadata.gz: e2120c7b926756b082e104665c021f7ffcd0d5a8
4
+ data.tar.gz: 47a4d29a2a673391a407e3029c400fdaf99de80e
5
5
  SHA512:
6
- metadata.gz: 77daeece70472dca00a5157a3db3cd1b2e5d9eb4ec14526bbe2d9b9680767afaa30df5386f108e4d6dcf66112cab48106981d987d2e3037aa1902fe8d73e624f
7
- data.tar.gz: 9ea6a5974b22f56cb695064cf8c9c1eca1222aecfd35aeca94288c27de4fb413aa3bfc49311e8e1bc4769a436c857a47dbd5bb405adb4549f1d4fa84e4034bcf
6
+ metadata.gz: 72315d74c0d7f32910b264617aa42624d6ad2c36a4c7df7a6fe90eb08a31d1ba1ed3a7bbe7d5a7dcb54759108981c7e74e51a07c3d289e742b3788f52054d707
7
+ data.tar.gz: 3695119c7cbda98a5d8c23f9779aad3539bf841851fa825dbaf192cb9ac93669f307b73fedb092b874fabdc67c7add030fccfb6414439b10783412ba1c292b50
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paid (0.0.1)
4
+ paid (0.0.2)
5
5
  json (~> 1.8.1)
6
6
  mime-types (>= 1.25, < 3.0)
7
7
  rest-client (~> 1.4)
@@ -27,6 +27,7 @@ require 'paid/certificate_blacklist'
27
27
  require 'paid/invoice'
28
28
  require 'paid/transaction'
29
29
  require 'paid/event'
30
+ require 'paid/alias'
30
31
 
31
32
  # Errors
32
33
  require 'paid/errors/paid_error'
@@ -0,0 +1,6 @@
1
+ module Paid
2
+ class Alias < APIResource
3
+ include Paid::APIOperations::List
4
+ include Paid::APIOperations::Create
5
+ end
6
+ end
@@ -8,7 +8,8 @@ module Paid
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
11
- "/v0/#{CGI.escape(class_name.downcase)}s"
11
+ require 'active_support/inflector'
12
+ "/v0/#{CGI.escape(class_name.downcase).pluralize}"
12
13
  end
13
14
 
14
15
  def url
@@ -3,5 +3,18 @@ module Paid
3
3
  include Paid::APIOperations::List
4
4
  include Paid::APIOperations::Update
5
5
  include Paid::APIOperations::Create
6
+
7
+ def issue(params={}, opts={})
8
+ api_key, headers = Util.parse_opts(opts)
9
+ response, api_key = Paid.request(
10
+ :post, issue_url, api_key || @api_key, params, headers)
11
+ refresh_from(response, api_key)
12
+ end
13
+
14
+ private
15
+
16
+ def issue_url
17
+ url + '/issue'
18
+ end
6
19
  end
7
20
  end
@@ -24,7 +24,8 @@ module Paid
24
24
  'transaction' => Transaction,
25
25
  'customer' => Customer,
26
26
  'event' => Event,
27
- 'invoice' => Invoice
27
+ 'invoice' => Invoice,
28
+ 'alias' => Alias
28
29
  }
29
30
  end
30
31
 
@@ -1,3 +1,3 @@
1
1
  module Paid
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
Binary file
@@ -0,0 +1,38 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Paid
4
+ class AliasTest < Test::Unit::TestCase
5
+ should "aliases should be listable" do
6
+ @mock.expects(:get).once.returns(test_response(test_alias_array))
7
+ c = Paid::Alias.all
8
+ assert c.data.kind_of? Array
9
+ c.each do |paid_alias|
10
+ assert paid_alias.kind_of?(Paid::Alias)
11
+ end
12
+ end
13
+
14
+ should "aliases should not be deletable" do
15
+ assert_raises NoMethodError do
16
+ @mock.expects(:get).once.returns(test_response(test_alias))
17
+ c = Paid::Alias.retrieve("test_alias")
18
+ c.delete
19
+ end
20
+ end
21
+
22
+ should "execute should return a new, fully executed alias when passed correct parameters" do
23
+ @mock.expects(:post).with do |url, api_key, params|
24
+ url == "#{Paid.api_base}/v0/aliases" && api_key.nil? && CGI.parse(params) == {
25
+ 'name' => ['test-alias'],
26
+ 'customer' => ['c_test_customer']
27
+ }
28
+ end.once.returns(test_response(test_alias))
29
+
30
+ a = Paid::Alias.create({
31
+ :name => 'test-alias',
32
+ :customer => 'c_test_customer'
33
+ })
34
+
35
+ assert a.name == 'test-alias'
36
+ end
37
+ end
38
+ end
@@ -14,13 +14,12 @@ module Paid
14
14
  assert_equal "inv_test_invoice", i.id
15
15
  end
16
16
 
17
- # should "pay should pay an invoice" do
18
- # @mock.expects(:get).once.returns(test_response(test_invoice))
19
- # i = Paid::Invoice.retrieve('in_test_invoice')
20
-
21
- # @mock.expects(:post).once.with('https://api.paidapi.com/v0/invoices/in_test_invoice/pay', nil, '').returns(test_response(test_paid_invoice))
22
- # i.pay
23
- # assert_equal nil, i.next_payment_attempt
24
- # end
17
+ should "charges should be issuable" do
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")
21
+ i.issue
22
+ assert !i.issued_at.nil?
23
+ end
25
24
  end
26
25
  end
@@ -11,6 +11,24 @@ module Paid
11
11
  m
12
12
  end
13
13
 
14
+ def test_alias(params={})
15
+ id = params[:id] || 'al_test_alias'
16
+ {
17
+ :object => "alias",
18
+ :id => id,
19
+ :name => 'test-alias',
20
+ :customer => 'c_test_customer'
21
+ }.merge(params)
22
+ end
23
+
24
+ def test_alias_array(params={})
25
+ {
26
+ :data => [test_alias, test_alias, test_alias],
27
+ :object => 'list',
28
+ :url => '/v0/aliases'
29
+ }
30
+ end
31
+
14
32
  def test_customer(params={})
15
33
  id = params[:id] || 'c_test_customer'
16
34
  {
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.1
4
+ version: 0.0.2
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-25 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -130,6 +130,7 @@ files:
130
130
  - lib/data/ca-certificates.crt
131
131
  - lib/paid.rb
132
132
  - lib/paid/account.rb
133
+ - lib/paid/alias.rb
133
134
  - lib/paid/api_operations/create.rb
134
135
  - lib/paid/api_operations/delete.rb
135
136
  - lib/paid/api_operations/list.rb
@@ -152,7 +153,9 @@ files:
152
153
  - lib/paid/version.rb
153
154
  - lib/tasks/paid_tasks.rake
154
155
  - paid.gemspec
156
+ - pkg/paid-0.0.1.gem
155
157
  - test/paid/account_test.rb
158
+ - test/paid/alias_test.rb
156
159
  - test/paid/api_resource_test.rb
157
160
  - test/paid/certificate_blacklist_test.rb
158
161
  - test/paid/customer_test.rb
@@ -190,6 +193,7 @@ specification_version: 4
190
193
  summary: Ruby bindings for Paid API
191
194
  test_files:
192
195
  - test/paid/account_test.rb
196
+ - test/paid/alias_test.rb
193
197
  - test/paid/api_resource_test.rb
194
198
  - test/paid/certificate_blacklist_test.rb
195
199
  - test/paid/customer_test.rb