paid 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/paid.rb +1 -0
- data/lib/paid/alias.rb +6 -0
- data/lib/paid/api_resource.rb +2 -1
- data/lib/paid/invoice.rb +13 -0
- data/lib/paid/util.rb +2 -1
- data/lib/paid/version.rb +1 -1
- data/pkg/paid-0.0.1.gem +0 -0
- data/test/paid/alias_test.rb +38 -0
- data/test/paid/invoice_test.rb +7 -8
- data/test/test_data.rb +18 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2120c7b926756b082e104665c021f7ffcd0d5a8
|
4
|
+
data.tar.gz: 47a4d29a2a673391a407e3029c400fdaf99de80e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72315d74c0d7f32910b264617aa42624d6ad2c36a4c7df7a6fe90eb08a31d1ba1ed3a7bbe7d5a7dcb54759108981c7e74e51a07c3d289e742b3788f52054d707
|
7
|
+
data.tar.gz: 3695119c7cbda98a5d8c23f9779aad3539bf841851fa825dbaf192cb9ac93669f307b73fedb092b874fabdc67c7add030fccfb6414439b10783412ba1c292b50
|
data/Gemfile.lock
CHANGED
data/lib/paid.rb
CHANGED
data/lib/paid/alias.rb
ADDED
data/lib/paid/api_resource.rb
CHANGED
@@ -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
|
-
|
11
|
+
require 'active_support/inflector'
|
12
|
+
"/v0/#{CGI.escape(class_name.downcase).pluralize}"
|
12
13
|
end
|
13
14
|
|
14
15
|
def url
|
data/lib/paid/invoice.rb
CHANGED
@@ -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
|
data/lib/paid/util.rb
CHANGED
data/lib/paid/version.rb
CHANGED
data/pkg/paid-0.0.1.gem
ADDED
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
|
data/test/paid/invoice_test.rb
CHANGED
@@ -14,13 +14,12 @@ module Paid
|
|
14
14
|
assert_equal "inv_test_invoice", i.id
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
data/test/test_data.rb
CHANGED
@@ -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.
|
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-
|
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
|