pin_up 0.4.2 → 0.5.0
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 +4 -4
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/pin_up.iml +59 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +328 -0
- data/.travis.yml +8 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +32 -0
- data/Guardfile +45 -0
- data/README.md +37 -0
- data/VERSION +1 -1
- data/lib/pin_up/base.rb +11 -4
- data/lib/pin_up/charge.rb +7 -2
- data/lib/pin_up/customer.rb +14 -5
- data/lib/pin_up/refund.rb +6 -2
- data/pin_up.gemspec +20 -28
- data/spec/charges_spec.rb +10 -2
- data/spec/customers_spec.rb +30 -3
- data/spec/errors_spec.rb +1 -1
- data/spec/refund_spec.rb +13 -4
- data/spec/spec_helper.rb +2 -0
- metadata +41 -27
- data/spec/vcr/Base/should_list_succesfully_connect_to_Pin.yml +0 -73
- data/spec/vcr/Card/should_create_a_card_and_respond_with_the_card_detail_from_pin.yml +0 -53
- data/spec/vcr/Charge/should_create_a_charge_given_details.yml +0 -52
- data/spec/vcr/Charge/should_list_charges_in_Pin.yml +0 -96
- data/spec/vcr/Charge/should_not_show_a_charge_if_end_date_is_out_of_range.yml +0 -50
- data/spec/vcr/Charge/should_show_a_charge_given_a_search_term.yml +0 -58
- data/spec/vcr/Charge/should_show_a_charge_given_a_token.yml +0 -53
- data/spec/vcr/Customer/should_create_a_customer_given_a_card_token_customer_email.yml +0 -101
- data/spec/vcr/Customer/should_create_a_customer_given_an_email_and_card_details.yml +0 -51
- data/spec/vcr/Customer/should_list_charges_to_a_customer_given_a_token.yml +0 -53
- data/spec/vcr/Customer/should_list_customers.yml +0 -65
- data/spec/vcr/Customer/should_raise_an_error_if_an_attribute_is_missing_in_the_card_hash.yml +0 -50
- data/spec/vcr/Customer/should_show_a_customer_given_a_token.yml +0 -51
- data/spec/vcr/Customer/should_update_a_customer_given_a_token_and_details_to_update.yml +0 -51
- data/spec/vcr/Errors/Should_raise_a_ResourceNotFound_error_when_can_t_find_customer.yml +0 -49
- data/spec/vcr/Errors/should_raise_a_400_error_when_trying_to_make_a_payment_and_a_valid_card_gets_declined.yml +0 -48
- data/spec/vcr/Errors/should_raise_a_404_error_when_looking_for_a_customer_that_doesn_t_exist.yml +0 -49
- data/spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_expired_card.yml +0 -50
- data/spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_invalid_card.yml +0 -50
- data/spec/vcr/Errors/should_raise_a_422_error_when_trying_to_update_missing_a_param.yml +0 -50
- data/spec/vcr/Errors/should_show_a_charge_given_a_token.yml +0 -53
- data/spec/vcr/Refund/should_create_a_refund_for_a_given_amount_and_charge.yml +0 -50
- data/spec/vcr/Refund/should_create_a_refund_for_the_entire_amount_of_a_charge_if_no_amount_given.yml +0 -50
- data/spec/vcr/Refund/should_list_all_refunds_made_to_a_charge_given_a_token.yml +0 -50
- data/spec/vcr/Refund/should_return_nothing_if_looking_for_a_charge_without_a_refund.yml +0 -50
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -10,11 +10,14 @@ GEM
|
|
|
10
10
|
addressable (2.3.5)
|
|
11
11
|
atomic (1.1.10)
|
|
12
12
|
builder (3.2.2)
|
|
13
|
+
coderay (1.0.9)
|
|
13
14
|
crack (0.4.0)
|
|
14
15
|
safe_yaml (~> 0.9.0)
|
|
15
16
|
diff-lcs (1.2.4)
|
|
16
17
|
faraday (0.8.7)
|
|
17
18
|
multipart-post (~> 1.1)
|
|
19
|
+
ffi (1.9.0)
|
|
20
|
+
formatador (0.2.4)
|
|
18
21
|
git (1.2.5)
|
|
19
22
|
github_api (0.10.1)
|
|
20
23
|
addressable
|
|
@@ -23,6 +26,15 @@ GEM
|
|
|
23
26
|
multi_json (~> 1.4)
|
|
24
27
|
nokogiri (~> 1.5.2)
|
|
25
28
|
oauth2
|
|
29
|
+
guard (1.8.1)
|
|
30
|
+
formatador (>= 0.2.4)
|
|
31
|
+
listen (>= 1.0.0)
|
|
32
|
+
lumberjack (>= 1.0.2)
|
|
33
|
+
pry (>= 0.9.10)
|
|
34
|
+
thor (>= 0.14.6)
|
|
35
|
+
guard-rspec (3.0.2)
|
|
36
|
+
guard (>= 1.8)
|
|
37
|
+
rspec (~> 2.13)
|
|
26
38
|
hashie (2.0.5)
|
|
27
39
|
highline (1.6.19)
|
|
28
40
|
httparty (0.11.0)
|
|
@@ -42,6 +54,12 @@ GEM
|
|
|
42
54
|
json (1.8.0)
|
|
43
55
|
jwt (0.1.8)
|
|
44
56
|
multi_json (>= 1.5)
|
|
57
|
+
listen (1.2.2)
|
|
58
|
+
rb-fsevent (>= 0.9.3)
|
|
59
|
+
rb-inotify (>= 0.9)
|
|
60
|
+
rb-kqueue (>= 0.2)
|
|
61
|
+
lumberjack (1.0.3)
|
|
62
|
+
method_source (0.8.1)
|
|
45
63
|
minitest (4.7.5)
|
|
46
64
|
multi_json (1.7.7)
|
|
47
65
|
multi_xml (0.5.4)
|
|
@@ -54,8 +72,17 @@ GEM
|
|
|
54
72
|
multi_json (~> 1.0)
|
|
55
73
|
multi_xml (~> 0.5)
|
|
56
74
|
rack (~> 1.2)
|
|
75
|
+
pry (0.9.12.2)
|
|
76
|
+
coderay (~> 1.0.5)
|
|
77
|
+
method_source (~> 0.8)
|
|
78
|
+
slop (~> 3.4)
|
|
57
79
|
rack (1.5.2)
|
|
58
80
|
rake (10.1.0)
|
|
81
|
+
rb-fsevent (0.9.3)
|
|
82
|
+
rb-inotify (0.9.0)
|
|
83
|
+
ffi (>= 0.5.0)
|
|
84
|
+
rb-kqueue (0.2.0)
|
|
85
|
+
ffi (>= 0.5.0)
|
|
59
86
|
rdoc (3.12.2)
|
|
60
87
|
json (~> 1.4)
|
|
61
88
|
rspec (2.13.0)
|
|
@@ -77,6 +104,9 @@ GEM
|
|
|
77
104
|
multi_json (~> 1.0)
|
|
78
105
|
simplecov-html (~> 0.7.1)
|
|
79
106
|
simplecov-html (0.7.1)
|
|
107
|
+
slop (3.4.5)
|
|
108
|
+
terminal-notifier-guard (1.5.3)
|
|
109
|
+
thor (0.18.1)
|
|
80
110
|
thread_safe (0.1.0)
|
|
81
111
|
atomic
|
|
82
112
|
tzinfo (0.3.37)
|
|
@@ -89,11 +119,13 @@ PLATFORMS
|
|
|
89
119
|
ruby
|
|
90
120
|
|
|
91
121
|
DEPENDENCIES
|
|
122
|
+
guard-rspec
|
|
92
123
|
httparty
|
|
93
124
|
jeweler (~> 1.8.4)
|
|
94
125
|
rdoc (~> 3.12)
|
|
95
126
|
rspec
|
|
96
127
|
shoulda
|
|
97
128
|
simplecov
|
|
129
|
+
terminal-notifier-guard
|
|
98
130
|
vcr
|
|
99
131
|
webmock
|
data/Guardfile
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
guard :rspec do
|
|
4
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
5
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
6
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
7
|
+
|
|
8
|
+
# Rails example
|
|
9
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
10
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
|
11
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
|
12
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
|
13
|
+
watch('config/routes.rb') { "spec/routing" }
|
|
14
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
|
15
|
+
|
|
16
|
+
# Capybara features specs
|
|
17
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
|
18
|
+
|
|
19
|
+
# Turnip features and steps
|
|
20
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
21
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
guard :rspec do
|
|
26
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
27
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
28
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
29
|
+
|
|
30
|
+
# Rails example
|
|
31
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
32
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
|
33
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
|
34
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
|
35
|
+
watch('config/routes.rb') { "spec/routing" }
|
|
36
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
|
37
|
+
|
|
38
|
+
# Capybara features specs
|
|
39
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
|
40
|
+
|
|
41
|
+
# Turnip features and steps
|
|
42
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
43
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
|
44
|
+
end
|
|
45
|
+
|
data/README.md
CHANGED
|
@@ -4,6 +4,8 @@ A Ruby gem wrapper for the pin-payments (pin.net.au) API, all of it.
|
|
|
4
4
|
|
|
5
5
|
Support for Ruby 1.9.x & Ruby 2.0.0
|
|
6
6
|
|
|
7
|
+
[](https://travis-ci.org/dNitza/pin_up)
|
|
8
|
+
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
11
|
gem install pin_up
|
|
@@ -25,6 +27,18 @@ An option second paramater can be passed in to set the environment (:live or :te
|
|
|
25
27
|
### Charges
|
|
26
28
|
##### List All Charges
|
|
27
29
|
Pin::Charges.all
|
|
30
|
+
|
|
31
|
+
Show charges on a particular page:
|
|
32
|
+
|
|
33
|
+
Pin::Charges.all(6)
|
|
34
|
+
|
|
35
|
+
With Pagination:
|
|
36
|
+
|
|
37
|
+
Pin::Charges.all(6,true)
|
|
38
|
+
# request = Pin::Charges.all(6,true)
|
|
39
|
+
# request[:response] => response hash
|
|
40
|
+
# request[:pagination] => "pagination":{"current":6,"previous":5,"next":7,"per_page":25,"pages":1,"count":15}
|
|
41
|
+
|
|
28
42
|
##### Find A Charge
|
|
29
43
|
Pin::Charges.find("token")
|
|
30
44
|
##### Search For A Charge
|
|
@@ -40,10 +54,31 @@ See https://pin.net.au/docs/api/charges#search-charges for a full list of option
|
|
|
40
54
|
### Customers
|
|
41
55
|
##### List All Customers
|
|
42
56
|
Pin::Customer.all
|
|
57
|
+
|
|
58
|
+
Show customers on a particular page:
|
|
59
|
+
|
|
60
|
+
Pin::Customer.all(3)
|
|
61
|
+
|
|
62
|
+
With Pagination:
|
|
63
|
+
|
|
64
|
+
Pin::Customer.all(3,true)
|
|
65
|
+
|
|
43
66
|
##### Find A Customer
|
|
44
67
|
Pin::Customer.find('token')
|
|
45
68
|
##### List Charges For A Customer
|
|
46
69
|
Pin::Customer.charges('cus_token')
|
|
70
|
+
|
|
71
|
+
Show customers on a particular page:
|
|
72
|
+
|
|
73
|
+
Pin::Customer.charges(6)
|
|
74
|
+
|
|
75
|
+
With Pagination:
|
|
76
|
+
|
|
77
|
+
Pin::Customer.all(6,true)
|
|
78
|
+
# request = Pin::Customer.all(6,true)
|
|
79
|
+
# request[:response] => response hash
|
|
80
|
+
# request[:pagination] => "pagination":{"current":6,"previous":5,"next":7,"per_page":25,"pages":1,"count":15}
|
|
81
|
+
|
|
47
82
|
##### Create A Customer
|
|
48
83
|
Pin::Customer.create(email, hash_of_customer_details)
|
|
49
84
|
|
|
@@ -110,6 +145,8 @@ Create a YAML file under 'spec' called 'test_data.yml' and add in:
|
|
|
110
145
|
|
|
111
146
|
PIN_SECRET: "your pin test secret"
|
|
112
147
|
|
|
148
|
+
uncomment line 13 in spec_helper.rb and
|
|
149
|
+
|
|
113
150
|
run
|
|
114
151
|
|
|
115
152
|
rspec spec/*.rb
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.5.0
|
data/lib/pin_up/base.rb
CHANGED
|
@@ -68,16 +68,23 @@ module Pin
|
|
|
68
68
|
|
|
69
69
|
##
|
|
70
70
|
# Builds a response of a collection if the response code is 200 otherwise an empty array is returned
|
|
71
|
-
def self.build_collection_response(response)
|
|
71
|
+
def self.build_collection_response(response, pagination=false)
|
|
72
72
|
models = []
|
|
73
73
|
if response.code == 200
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
if pagination
|
|
75
|
+
response.parsed_response['response'].each do |model|
|
|
76
|
+
models << model
|
|
77
|
+
end
|
|
78
|
+
return {response: models, pagination: response.parsed_response['pagination']}
|
|
79
|
+
else
|
|
80
|
+
response.parsed_response['response'].each do |model|
|
|
81
|
+
models << model
|
|
82
|
+
end
|
|
76
83
|
end
|
|
77
84
|
elsif response.code >= 400
|
|
78
85
|
Pin::PinError.handle_error(response.code, response.parsed_response)
|
|
79
86
|
end
|
|
80
|
-
models
|
|
87
|
+
# models
|
|
81
88
|
end
|
|
82
89
|
end
|
|
83
90
|
end
|
data/lib/pin_up/charge.rb
CHANGED
|
@@ -4,10 +4,15 @@ module Pin
|
|
|
4
4
|
class Charges < Base
|
|
5
5
|
##
|
|
6
6
|
# Lists all of the charges for your account
|
|
7
|
+
# args: page (Fixnum), pagination (Boolean)
|
|
7
8
|
# returns: a collection of charge objects
|
|
9
|
+
#
|
|
10
|
+
# if pagination is passed, access the response hash with [:response]
|
|
11
|
+
# and the pagination hash with [:pagination]
|
|
12
|
+
#
|
|
8
13
|
# https://pin.net.au/docs/api/charges#get-charges
|
|
9
|
-
def self.all
|
|
10
|
-
|
|
14
|
+
def self.all(page=nil, pagination=false)
|
|
15
|
+
build_collection_response(auth_get("charges?page=#{page}"),pagination)
|
|
11
16
|
end
|
|
12
17
|
|
|
13
18
|
##
|
data/lib/pin_up/customer.rb
CHANGED
|
@@ -5,10 +5,15 @@ module Pin
|
|
|
5
5
|
|
|
6
6
|
##
|
|
7
7
|
# Lists all customers for your account
|
|
8
|
+
# args: page (Fixnum), pagination (Boolean)
|
|
8
9
|
# returns: a collection of customer objects
|
|
10
|
+
#
|
|
11
|
+
# if pagination is passed, access the response hash with [:response]
|
|
12
|
+
# and the pagination hash with [:pagination]
|
|
13
|
+
#
|
|
9
14
|
# https://pin.net.au/docs/api/customers#get-customers
|
|
10
|
-
def self.all
|
|
11
|
-
build_collection_response(auth_get(
|
|
15
|
+
def self.all(page=nil, pagination=false)
|
|
16
|
+
build_collection_response(auth_get("customers?page=#{page}"), pagination)
|
|
12
17
|
end
|
|
13
18
|
|
|
14
19
|
##
|
|
@@ -47,11 +52,15 @@ module Pin
|
|
|
47
52
|
|
|
48
53
|
##
|
|
49
54
|
# Get a list of charges for a customer
|
|
50
|
-
# args: token (String)
|
|
55
|
+
# args: token (String), page (Fixnum), pagination (Boolean)
|
|
51
56
|
# returns: a collection of charge objects
|
|
57
|
+
#
|
|
58
|
+
# if pagination is passed, access the response hash with [:response]
|
|
59
|
+
# and the pagination hash with [:pagination]
|
|
60
|
+
#
|
|
52
61
|
# https://pin.net.au/docs/api/customers#get-customers-charges
|
|
53
|
-
def self.charges(token)
|
|
54
|
-
build_collection_response(auth_get("customers/#{token}/charges"))
|
|
62
|
+
def self.charges(token, page=nil, pagination=false)
|
|
63
|
+
build_collection_response(auth_get("customers/#{token}/charges?page=#{page}"), pagination)
|
|
55
64
|
end
|
|
56
65
|
end
|
|
57
66
|
end
|
data/lib/pin_up/refund.rb
CHANGED
|
@@ -7,9 +7,13 @@ module Pin
|
|
|
7
7
|
# Find a refund by charge token
|
|
8
8
|
# returns: a collection of refund objects
|
|
9
9
|
# args: token (String)
|
|
10
|
+
#
|
|
11
|
+
# if pagination is passed, access the response hash with [:response]
|
|
12
|
+
# and the pagination hash with [:pagination]
|
|
13
|
+
#
|
|
10
14
|
# https://pin.net.au/docs/api/refunds#get-refunds
|
|
11
|
-
def self.find(token)
|
|
12
|
-
build_collection_response(auth_get("charges/#{token}/refunds"))
|
|
15
|
+
def self.find(token, page = nil, pagination = false)
|
|
16
|
+
build_collection_response(auth_get("charges/#{token}/refunds?page=#{page}"), pagination)
|
|
13
17
|
end
|
|
14
18
|
|
|
15
19
|
##
|
data/pin_up.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "pin_up"
|
|
8
|
-
s.version = "0.
|
|
8
|
+
s.version = "0.5.0"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Daniel Nitsikopoulos"]
|
|
12
|
-
s.date = "2013-
|
|
12
|
+
s.date = "2013-08-18"
|
|
13
13
|
s.description = "A Ruby gem wrapper for the pin-payments (pin.net.au) API"
|
|
14
14
|
s.email = "dnitza@gmail.com"
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -18,8 +18,19 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
]
|
|
19
19
|
s.files = [
|
|
20
20
|
".document",
|
|
21
|
+
".idea/.name",
|
|
22
|
+
".idea/.rakeTasks",
|
|
23
|
+
".idea/encodings.xml",
|
|
24
|
+
".idea/misc.xml",
|
|
25
|
+
".idea/modules.xml",
|
|
26
|
+
".idea/pin_up.iml",
|
|
27
|
+
".idea/scopes/scope_settings.xml",
|
|
28
|
+
".idea/vcs.xml",
|
|
29
|
+
".idea/workspace.xml",
|
|
30
|
+
".travis.yml",
|
|
21
31
|
"Gemfile",
|
|
22
32
|
"Gemfile.lock",
|
|
33
|
+
"Guardfile",
|
|
23
34
|
"LICENSE.txt",
|
|
24
35
|
"README.md",
|
|
25
36
|
"Rakefile",
|
|
@@ -39,32 +50,7 @@ Gem::Specification.new do |s|
|
|
|
39
50
|
"spec/customers_spec.rb",
|
|
40
51
|
"spec/errors_spec.rb",
|
|
41
52
|
"spec/refund_spec.rb",
|
|
42
|
-
"spec/spec_helper.rb"
|
|
43
|
-
"spec/vcr/Base/should_list_succesfully_connect_to_Pin.yml",
|
|
44
|
-
"spec/vcr/Card/should_create_a_card_and_respond_with_the_card_detail_from_pin.yml",
|
|
45
|
-
"spec/vcr/Charge/should_create_a_charge_given_details.yml",
|
|
46
|
-
"spec/vcr/Charge/should_list_charges_in_Pin.yml",
|
|
47
|
-
"spec/vcr/Charge/should_not_show_a_charge_if_end_date_is_out_of_range.yml",
|
|
48
|
-
"spec/vcr/Charge/should_show_a_charge_given_a_search_term.yml",
|
|
49
|
-
"spec/vcr/Charge/should_show_a_charge_given_a_token.yml",
|
|
50
|
-
"spec/vcr/Customer/should_create_a_customer_given_a_card_token_customer_email.yml",
|
|
51
|
-
"spec/vcr/Customer/should_create_a_customer_given_an_email_and_card_details.yml",
|
|
52
|
-
"spec/vcr/Customer/should_list_charges_to_a_customer_given_a_token.yml",
|
|
53
|
-
"spec/vcr/Customer/should_list_customers.yml",
|
|
54
|
-
"spec/vcr/Customer/should_raise_an_error_if_an_attribute_is_missing_in_the_card_hash.yml",
|
|
55
|
-
"spec/vcr/Customer/should_show_a_customer_given_a_token.yml",
|
|
56
|
-
"spec/vcr/Customer/should_update_a_customer_given_a_token_and_details_to_update.yml",
|
|
57
|
-
"spec/vcr/Errors/Should_raise_a_ResourceNotFound_error_when_can_t_find_customer.yml",
|
|
58
|
-
"spec/vcr/Errors/should_raise_a_400_error_when_trying_to_make_a_payment_and_a_valid_card_gets_declined.yml",
|
|
59
|
-
"spec/vcr/Errors/should_raise_a_404_error_when_looking_for_a_customer_that_doesn_t_exist.yml",
|
|
60
|
-
"spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_expired_card.yml",
|
|
61
|
-
"spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_invalid_card.yml",
|
|
62
|
-
"spec/vcr/Errors/should_raise_a_422_error_when_trying_to_update_missing_a_param.yml",
|
|
63
|
-
"spec/vcr/Errors/should_show_a_charge_given_a_token.yml",
|
|
64
|
-
"spec/vcr/Refund/should_create_a_refund_for_a_given_amount_and_charge.yml",
|
|
65
|
-
"spec/vcr/Refund/should_create_a_refund_for_the_entire_amount_of_a_charge_if_no_amount_given.yml",
|
|
66
|
-
"spec/vcr/Refund/should_list_all_refunds_made_to_a_charge_given_a_token.yml",
|
|
67
|
-
"spec/vcr/Refund/should_return_nothing_if_looking_for_a_charge_without_a_refund.yml"
|
|
53
|
+
"spec/spec_helper.rb"
|
|
68
54
|
]
|
|
69
55
|
s.homepage = "http://github.com/dNitza/pin_up"
|
|
70
56
|
s.licenses = ["MIT"]
|
|
@@ -85,6 +71,8 @@ Gem::Specification.new do |s|
|
|
|
85
71
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
|
86
72
|
s.add_development_dependency(%q<webmock>, [">= 0"])
|
|
87
73
|
s.add_development_dependency(%q<vcr>, [">= 0"])
|
|
74
|
+
s.add_development_dependency(%q<guard-rspec>, [">= 0"])
|
|
75
|
+
s.add_development_dependency(%q<terminal-notifier-guard>, [">= 0"])
|
|
88
76
|
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
|
89
77
|
else
|
|
90
78
|
s.add_dependency(%q<httparty>, [">= 0"])
|
|
@@ -96,6 +84,8 @@ Gem::Specification.new do |s|
|
|
|
96
84
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
97
85
|
s.add_dependency(%q<webmock>, [">= 0"])
|
|
98
86
|
s.add_dependency(%q<vcr>, [">= 0"])
|
|
87
|
+
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
|
88
|
+
s.add_dependency(%q<terminal-notifier-guard>, [">= 0"])
|
|
99
89
|
s.add_dependency(%q<httparty>, [">= 0"])
|
|
100
90
|
end
|
|
101
91
|
else
|
|
@@ -108,6 +98,8 @@ Gem::Specification.new do |s|
|
|
|
108
98
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
109
99
|
s.add_dependency(%q<webmock>, [">= 0"])
|
|
110
100
|
s.add_dependency(%q<vcr>, [">= 0"])
|
|
101
|
+
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
|
102
|
+
s.add_dependency(%q<terminal-notifier-guard>, [">= 0"])
|
|
111
103
|
s.add_dependency(%q<httparty>, [">= 0"])
|
|
112
104
|
end
|
|
113
105
|
end
|
data/spec/charges_spec.rb
CHANGED
|
@@ -10,7 +10,7 @@ describe "Charge", :vcr, class: Pin::Charges do
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "should show a charge given a token" do
|
|
13
|
-
Pin::Charges.find("ch_0kdOMXP7gG0_W_Vh8qAWdA")["token"].should
|
|
13
|
+
Pin::Charges.find("ch_0kdOMXP7gG0_W_Vh8qAWdA")["token"].should match(/^[a-z]{2}[_]/)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "should show a charge given a search term" do
|
|
@@ -22,7 +22,15 @@ describe "Charge", :vcr, class: Pin::Charges do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it "should create a charge given details" do
|
|
25
|
-
options = {email: "dNitza@gmail.com", description: "A new charge from testing Pin gem", amount: "400", currency: "AUD", ip_address: "127.0.0.1", customer_token: "
|
|
25
|
+
options = {email: "dNitza@gmail.com", description: "A new charge from testing Pin gem", amount: "400", currency: "AUD", ip_address: "127.0.0.1", customer_token: "cus_8ImkZdEZ6BXUA6NcJDZg_g" }
|
|
26
26
|
Pin::Charges.create(options)["success"].should eq true
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
it "should return pagination if 'pagination' is true" do
|
|
30
|
+
Pin::Charges.all(3,true)[:pagination]["current"] == 3
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should list charges on a page given a page" do
|
|
34
|
+
Pin::Charges.all(1).should_not == []
|
|
35
|
+
end
|
|
28
36
|
end
|
data/spec/customers_spec.rb
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
describe "Customer", :vcr, class: Pin::Customer do
|
|
5
4
|
before(:each) do
|
|
6
5
|
Pin::Base.new(ENV["PIN_SECRET"], :test)
|
|
7
6
|
end
|
|
8
7
|
|
|
9
8
|
it "should list customers" do
|
|
10
|
-
Pin::Customer.all.should_not ==
|
|
9
|
+
Pin::Customer.all.should_not == []
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should go to a specific page when page paramater is passed" do
|
|
13
|
+
request = Pin::Customer.all(20,true)
|
|
14
|
+
request[:pagination]["current"].should == 20
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should list customers on a page given a page" do
|
|
18
|
+
request = Pin::Customer.all(1,true)
|
|
19
|
+
request[:response].should_not == []
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should return pagination if true is passed for pagination" do
|
|
23
|
+
request = Pin::Customer.all(1,true)
|
|
24
|
+
request[:pagination].keys.include?(["current", "previous", "next", "per_page", "pages", "count"])
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should not list customers on a page given a page if there are no customers" do
|
|
28
|
+
request = Pin::Customer.all(25,true)
|
|
29
|
+
request[:response].should == []
|
|
11
30
|
end
|
|
12
31
|
|
|
13
32
|
it "should show a customer given a token" do
|
|
@@ -15,7 +34,15 @@ describe "Customer", :vcr, class: Pin::Customer do
|
|
|
15
34
|
end
|
|
16
35
|
|
|
17
36
|
it "should list charges to a customer given a token" do
|
|
18
|
-
Pin::Customer.charges('cus_8ImkZdEZ6BXUA6NcJDZg_g')[0]['token'].should
|
|
37
|
+
Pin::Customer.charges('cus_8ImkZdEZ6BXUA6NcJDZg_g')[0]['token'].should match(/^[a-z]{2}[_]/)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should show pagination on a page given a token and a page" do
|
|
41
|
+
Pin::Customer.charges('cus_8ImkZdEZ6BXUA6NcJDZg_g',5,true)[:pagination]["current"] == 5
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should list charges to a customer on a page given a token and a page" do
|
|
45
|
+
Pin::Customer.charges('cus_8ImkZdEZ6BXUA6NcJDZg_g',1,true)[:response][0]['token'].should match(/^[a-z]{2}[_]/)
|
|
19
46
|
end
|
|
20
47
|
|
|
21
48
|
it "should create a customer given an email and card details" do
|