accepton 0.2.0 → 0.3.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/CHANGELOG.md +10 -0
- data/lib/accepton.rb +2 -0
- data/lib/accepton/api/planning.rb +31 -0
- data/lib/accepton/api/querying.rb +62 -3
- data/lib/accepton/api/subscribing.rb +21 -0
- data/lib/accepton/client.rb +4 -0
- data/lib/accepton/plan.rb +21 -0
- data/lib/accepton/subscription.rb +30 -0
- data/lib/accepton/version.rb +1 -1
- 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: c2d8dd63ba217851acd3120adcd40c3a36484fb7
|
4
|
+
data.tar.gz: ddc86a631827bf9e42d4a8c6ac4c40e2d31943fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ed685a6ed7c27c5df7c16de285e4e2ca448c8ca3e044860b21a2bf8e83e88a59291e77852035bdf4495f29b089a017e395920dbf6dab5c53dc39b9aa4988f6
|
7
|
+
data.tar.gz: 52431b8ac177a975f574418e292949a1449e3468a7327ee7e69f9fd76dda344d8e58581b5ca47c340706a42653cc3caa33c6cbf235a2a84d1989a5d5a543f00b
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,15 @@ scheme are considered to be bugs.
|
|
6
6
|
|
7
7
|
[semver]: http://semver.org/spec/v2.0.0.html
|
8
8
|
|
9
|
+
## [0.3.0][0.3.0] - 2015-11-06
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Added support for creating plans.
|
14
|
+
- Added support for querying singular and lists of plans.
|
15
|
+
- Added support for cancelling subscriptions.
|
16
|
+
- Added support for querying singular and lists of subscriptions.
|
17
|
+
|
9
18
|
## [0.2.0][0.2.0] - 2015-09-18
|
10
19
|
|
11
20
|
### Added
|
@@ -18,5 +27,6 @@ scheme are considered to be bugs.
|
|
18
27
|
|
19
28
|
- Initial version.
|
20
29
|
|
30
|
+
[0.3.0]: https://github.com/accepton/accepton-ruby/compare/v0.2.0...v0.3.0
|
21
31
|
[0.2.0]: https://github.com/accepton/accepton-ruby/compare/v0.1.0...v0.2.0
|
22
32
|
[unreleased]: https://github.com/accepton/accepton-ruby/compare/v0.2.0...HEAD
|
data/lib/accepton.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'accepton/api/utils'
|
2
|
+
|
3
|
+
module AcceptOn
|
4
|
+
module API
|
5
|
+
module Planning
|
6
|
+
include AcceptOn::API::Utils
|
7
|
+
|
8
|
+
# Creates a plan on AcceptOn
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
# @example Create a plan named "Test plan"
|
13
|
+
# create_plan(name: 'Test Plan',
|
14
|
+
# currency: 'usd',
|
15
|
+
# amount: 20_00,
|
16
|
+
# period_unit: 'year')
|
17
|
+
#
|
18
|
+
# @param args [Hash]
|
19
|
+
# @option args [String] :name The plan name.
|
20
|
+
# @option args [String] :currency The currency to be used, in ISO 4217 format.
|
21
|
+
# @option args [Numeric] :amount The plan amount.
|
22
|
+
# @option args [String] :period_unit The billing frequency unit, (in month or year only).
|
23
|
+
#
|
24
|
+
# @raise [AcceptOn::Error] If an API error happens
|
25
|
+
# @return [AcceptOn::Plan] The created plan
|
26
|
+
def create_plan(args = {})
|
27
|
+
perform_post_with_object('/v1/plans', args, AcceptOn::Plan)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -11,7 +11,7 @@ module AcceptOn
|
|
11
11
|
#
|
12
12
|
# @param id [String] The charge identifier
|
13
13
|
#
|
14
|
-
# @
|
14
|
+
# @raise [AcceptOn::Error]
|
15
15
|
# @return [AcceptOn::Charge]
|
16
16
|
def charge(id)
|
17
17
|
perform_get_with_object("/v1/charges/#{id}", {}, AcceptOn::Charge)
|
@@ -29,12 +29,71 @@ module AcceptOn
|
|
29
29
|
# @option args [String] :order The order to sort by (asc or desc).
|
30
30
|
# @option args [String] :order_by The field to order by (e.g. created_at).
|
31
31
|
#
|
32
|
-
# @
|
32
|
+
# @raise [AcceptOn::Error]
|
33
33
|
# @return [AcceptOn::Charge]
|
34
34
|
def charges(args = {})
|
35
35
|
perform_get_with_objects('/v1/charges', args, AcceptOn::Charge)
|
36
36
|
end
|
37
37
|
|
38
|
+
# Retrieves a plan from the API
|
39
|
+
#
|
40
|
+
# @api public
|
41
|
+
#
|
42
|
+
# @param id [String] The plan identifier
|
43
|
+
#
|
44
|
+
# @raise [AcceptOn::Error]
|
45
|
+
# @return [AcceptOn::Plan]
|
46
|
+
def plan(id)
|
47
|
+
perform_get_with_object("/v1/plans/#{id}", {}, AcceptOn::Plan)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Retrieves a list of all plans from the API
|
51
|
+
#
|
52
|
+
# @api public
|
53
|
+
#
|
54
|
+
# @param args [Hash] A hash of query parameters
|
55
|
+
# @option args [String] :order The order to sort by (asc or desc).
|
56
|
+
# @option args [String] :order_by The field to order by (e.g. created_at).
|
57
|
+
# @option args [Integer] :page The page number to retrieve.
|
58
|
+
# @option args [Integer] :per_page The size of the page to retrieve (max: 100).
|
59
|
+
# @option args [String, Symbol] :period_unit The period unit to filter by.
|
60
|
+
#
|
61
|
+
# @raise [AcceptOn::Error]
|
62
|
+
# @return [AcceptOn::Plan]
|
63
|
+
def plans(args = {})
|
64
|
+
perform_get_with_objects('/v1/plans', args, AcceptOn::Plan)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Retrieves a subscription from AcceptOn
|
68
|
+
#
|
69
|
+
# @api public
|
70
|
+
#
|
71
|
+
# @param id [String] The subscription identifier.
|
72
|
+
#
|
73
|
+
# @raise [AcceptOn::Error]
|
74
|
+
# @return [AcceptOn::Subscription]
|
75
|
+
def subscription(id)
|
76
|
+
perform_get_with_object("/v1/subscriptions/#{id}", {}, AcceptOn::Subscription)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Retrieves a page of subscriptions from AcceptOn
|
80
|
+
#
|
81
|
+
# @api public
|
82
|
+
#
|
83
|
+
# @param args [Hash] A hash of query parameters
|
84
|
+
# @option args [String] :order The order to sort by (asc or desc).
|
85
|
+
# @option args [String] :order_by The field to order by (e.g. created_at).
|
86
|
+
# @option args [Integer] :page The page number to retrieve.
|
87
|
+
# @option args [Integer] :per_page The size of the page to retrieve (max: 100).
|
88
|
+
# @option args [Boolean] :active The activity status of the subscription to filter by.
|
89
|
+
# @option args [String] 'plan.token' The plan id of the subscription to filter by.
|
90
|
+
#
|
91
|
+
# @raise [AcceptOn::Error]
|
92
|
+
# @return [AcceptOn::Subscription>]
|
93
|
+
def subscriptions(args = {})
|
94
|
+
perform_get_with_objects('/v1/subscriptions', args, AcceptOn::Subscription)
|
95
|
+
end
|
96
|
+
|
38
97
|
# Retrieves a promo code from AcceptOn
|
39
98
|
#
|
40
99
|
# @api public
|
@@ -76,7 +135,7 @@ module AcceptOn
|
|
76
135
|
#
|
77
136
|
# @param id [String] The transaction token identifier
|
78
137
|
#
|
79
|
-
# @
|
138
|
+
# @raise [AcceptOn::Error]
|
80
139
|
# @return [AcceptOn::TransactionToken]
|
81
140
|
def token(id)
|
82
141
|
perform_get_with_object("/v1/tokens/#{id}", {}, AcceptOn::TransactionToken)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'accepton/api/utils'
|
2
|
+
|
3
|
+
module AcceptOn
|
4
|
+
module API
|
5
|
+
module Subscribing
|
6
|
+
include AcceptOn::API::Utils
|
7
|
+
|
8
|
+
# Cancels a subscription on AcceptOn
|
9
|
+
#
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
# @param id [String] The subscription identifier
|
13
|
+
#
|
14
|
+
# @raises [AcceptOn::Error]
|
15
|
+
# @return [AcceptOn::Subscription]
|
16
|
+
def cancel_subscription(id)
|
17
|
+
perform_post_with_object("/v1/subscriptions/#{id}/cancel", {}, AcceptOn::Subscription)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/accepton/client.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
+
require 'accepton/api/planning'
|
1
2
|
require 'accepton/api/promotion'
|
2
3
|
require 'accepton/api/querying'
|
3
4
|
require 'accepton/api/refunding'
|
5
|
+
require 'accepton/api/subscribing'
|
4
6
|
require 'accepton/api/tokenization'
|
5
7
|
|
6
8
|
module AcceptOn
|
7
9
|
class Client
|
10
|
+
include AcceptOn::API::Planning
|
8
11
|
include AcceptOn::API::Promotion
|
9
12
|
include AcceptOn::API::Querying
|
10
13
|
include AcceptOn::API::Refunding
|
14
|
+
include AcceptOn::API::Subscribing
|
11
15
|
include AcceptOn::API::Tokenization
|
12
16
|
|
13
17
|
attr_accessor :api_key, :environment
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module AcceptOn
|
2
|
+
class Plan < Base
|
3
|
+
# @attr_reader amount [Integer] The amount of the plan in cents
|
4
|
+
# @attr_reader currency [String] The ISO currency code of the refund
|
5
|
+
# @attr_reader id [String] The plan identifier
|
6
|
+
# @attr_reader name [String] The name of the plan
|
7
|
+
# @attr_reader period_unit [String] the billing frequency unit of the plan
|
8
|
+
#
|
9
|
+
# @api public
|
10
|
+
attr_reader :amount, :currency, :id, :name, :period_unit
|
11
|
+
|
12
|
+
# The time the plan was created
|
13
|
+
#
|
14
|
+
# @api public
|
15
|
+
#
|
16
|
+
# @return [Time]
|
17
|
+
def created_at
|
18
|
+
Time.parse(@created_at).utc unless @created_at.nil?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module AcceptOn
|
2
|
+
class Subscription < Base
|
3
|
+
# @attr_reader active [Boolean] The activity status of the subscription
|
4
|
+
# @attr_reader email [String] The email belonging to the subscription
|
5
|
+
# @attr_reader id [String] The subscription identifier
|
6
|
+
#
|
7
|
+
# @api public
|
8
|
+
attr_reader :active, :email, :id
|
9
|
+
|
10
|
+
alias_method :active?, :active
|
11
|
+
|
12
|
+
# The time the subscription was last billed
|
13
|
+
#
|
14
|
+
# @api public
|
15
|
+
#
|
16
|
+
# @return [Time]
|
17
|
+
def last_billed_at
|
18
|
+
Time.parse(@last_billed_at).utc unless @last_billed_at.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
# The plan the subscription is connected to
|
22
|
+
#
|
23
|
+
# @api public
|
24
|
+
#
|
25
|
+
# @return [AcceptOn::Plan]
|
26
|
+
def plan
|
27
|
+
AcceptOn::Plan.new(@plan)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/accepton/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accepton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AcceptOn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -66,9 +66,11 @@ files:
|
|
66
66
|
- Rakefile
|
67
67
|
- accepton.gemspec
|
68
68
|
- lib/accepton.rb
|
69
|
+
- lib/accepton/api/planning.rb
|
69
70
|
- lib/accepton/api/promotion.rb
|
70
71
|
- lib/accepton/api/querying.rb
|
71
72
|
- lib/accepton/api/refunding.rb
|
73
|
+
- lib/accepton/api/subscribing.rb
|
72
74
|
- lib/accepton/api/tokenization.rb
|
73
75
|
- lib/accepton/api/utils.rb
|
74
76
|
- lib/accepton/base.rb
|
@@ -76,9 +78,11 @@ files:
|
|
76
78
|
- lib/accepton/client.rb
|
77
79
|
- lib/accepton/error.rb
|
78
80
|
- lib/accepton/headers.rb
|
81
|
+
- lib/accepton/plan.rb
|
79
82
|
- lib/accepton/promo_code.rb
|
80
83
|
- lib/accepton/refund.rb
|
81
84
|
- lib/accepton/request.rb
|
85
|
+
- lib/accepton/subscription.rb
|
82
86
|
- lib/accepton/transaction_token.rb
|
83
87
|
- lib/accepton/version.rb
|
84
88
|
homepage: https://developers.accepton.com
|