Class: Smartcoin::Subscription

Inherits:
SmartcoinObject show all
Includes:
ApiOperations::Create, ApiOperations::Delete, ApiOperations::List, ApiOperations::Retrieve, ApiOperations::Update, ApiResource
Defined in:
lib/smartcoin/subscription.rb

Constant Summary

Constants included from ApiResource

ApiResource::BASE_URL, ApiResource::SSL_BUNDLE_PATH

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApiOperations::List

included, #list_all

Methods included from ApiOperations::Update

#save, #update

Methods included from ApiOperations::Retrieve

included, #retrieve

Methods included from ApiOperations::Create

#create, included

Methods included from ApiResource

#api_request, #encode, included, #url_encode

Methods inherited from SmartcoinObject

class_name, #create_fields, create_from, #initialize, #metaclass, #method_missing, #reflesh_object, #set_properties, #to_hash, #to_json, #to_s, url

Constructor Details

This class inherits a constructor from Smartcoin::SmartcoinObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Smartcoin::SmartcoinObject

Class Method Details

.list_allObject



26
27
28
29
30
# File 'lib/smartcoin/subscription.rb', line 26

def self.list_all
  method = :get
  response = api_request(url, method)
  create_from(response)
end

Instance Method Details

#class_nameObject



10
11
12
# File 'lib/smartcoin/subscription.rb', line 10

def class_name
  Smartcoin::Subscription.class_name
end

#create_from(params) ⇒ Object



14
15
16
# File 'lib/smartcoin/subscription.rb', line 14

def create_from(params)
  Smartcoin::Subscription.create_from(params)
end

#deleteObject



32
33
34
35
36
37
# File 'lib/smartcoin/subscription.rb', line 32

def delete
  method = :delete
  response = api_request("#{url}/#{self.id}",method)
  reflesh_object(response)
  response
end

#serialize_paramsObject



18
19
20
# File 'lib/smartcoin/subscription.rb', line 18

def serialize_params
  [:plan, :quantity]
end

#urlObject



22
23
24
# File 'lib/smartcoin/subscription.rb', line 22

def url
  "#{Smartcoin::Customer.url}/#{CGI.escape(self.customer)}/#{CGI.escape(class_name.downcase)}s"
end