Class: Cryptopay::Subscriptions
- Inherits:
-
Object
- Object
- Cryptopay::Subscriptions
- Defined in:
- lib/cryptopay/api/subscriptions.rb
Instance Method Summary collapse
-
#cancel(subscription_id, _opts = {}) ⇒ SubscriptionResult
Cancel a subscription.
-
#create(subscription_params, _opts = {}) ⇒ SubscriptionResult
Create a subscription.
-
#initialize(connection) ⇒ Subscriptions
constructor
A new instance of Subscriptions.
-
#list(opts = {}) ⇒ SubscriptionListResult
List subscriptions.
-
#retrieve(subscription_id, _opts = {}) ⇒ SubscriptionResult
Retrieve a subscription.
-
#retrieve_by_custom_id(custom_id, _opts = {}) ⇒ SubscriptionResult
Retrieve a subscription by custom_id.
Constructor Details
#initialize(connection) ⇒ Subscriptions
Returns a new instance of Subscriptions.
8 9 10 |
# File 'lib/cryptopay/api/subscriptions.rb', line 8 def initialize(connection) @connection = connection end |
Instance Method Details
#cancel(subscription_id, _opts = {}) ⇒ SubscriptionResult
Cancel a subscription
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cryptopay/api/subscriptions.rb', line 16 def cancel(subscription_id, _opts = {}) path = '/api/subscriptions/{subscription_id}/cancel' path = path.sub('{subscription_id}', CGI.escape(subscription_id.to_s)) req = Request.new( method: :post, path: path ) connection.call(req, return_type: SubscriptionResult) end |
#create(subscription_params, _opts = {}) ⇒ SubscriptionResult
Create a subscription
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cryptopay/api/subscriptions.rb', line 32 def create(subscription_params, _opts = {}) path = '/api/subscriptions' req = Request.new( method: :post, path: path, body_params: subscription_params ) connection.call(req, return_type: SubscriptionResult) end |
#list(opts = {}) ⇒ SubscriptionListResult
List subscriptions
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cryptopay/api/subscriptions.rb', line 48 def list(opts = {}) path = '/api/subscriptions' query_params = {} query_params[:starting_after] = opts[:starting_after] unless opts[:starting_after].nil? req = Request.new( method: :get, path: path, query_params: query_params ) connection.call(req, return_type: SubscriptionListResult) end |
#retrieve(subscription_id, _opts = {}) ⇒ SubscriptionResult
Retrieve a subscription
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cryptopay/api/subscriptions.rb', line 67 def retrieve(subscription_id, _opts = {}) path = '/api/subscriptions/{subscription_id}' path = path.sub('{subscription_id}', CGI.escape(subscription_id.to_s)) req = Request.new( method: :get, path: path ) connection.call(req, return_type: SubscriptionResult) end |
#retrieve_by_custom_id(custom_id, _opts = {}) ⇒ SubscriptionResult
Retrieve a subscription by custom_id
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cryptopay/api/subscriptions.rb', line 83 def retrieve_by_custom_id(custom_id, _opts = {}) path = '/api/subscriptions/custom_id/{custom_id}' path = path.sub('{custom_id}', CGI.escape(custom_id.to_s)) req = Request.new( method: :get, path: path ) connection.call(req, return_type: SubscriptionResult) end |