Class: Paid::Subscription

Inherits:
APIResource show all
Defined in:
lib/paid/subscription.rb

Instance Attribute Summary collapse

Attributes inherited from APIResource

#api_method, #json

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIResource

api_attribute_names, #api_attributes, api_subclass_fetch, api_subclasses, #changed_api_attributes, #clear_api_attributes, #determine_api_attribute_value, determine_api_attribute_value, #initialize, #inspect, #inspect_api_attributes, #inspect_nested, #refresh_from, register_api_subclass, #to_json

Constructor Details

This class inherits a constructor from Paid::APIResource

Instance Attribute Details

#cancelled_atObject

Returns the value of attribute cancelled_at.



13
14
15
# File 'lib/paid/subscription.rb', line 13

def cancelled_at
  @cancelled_at
end

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/paid/subscription.rb', line 5

def created_at
  @created_at
end

#customerObject

Returns the value of attribute customer.



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

def customer
  @customer
end

#ended_atObject

Returns the value of attribute ended_at.



12
13
14
# File 'lib/paid/subscription.rb', line 12

def ended_at
  @ended_at
end

#ends_onObject

Returns the value of attribute ends_on.



7
8
9
# File 'lib/paid/subscription.rb', line 7

def ends_on
  @ends_on
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/paid/subscription.rb', line 3

def id
  @id
end

#next_transaction_onObject

Returns the value of attribute next_transaction_on.



8
9
10
# File 'lib/paid/subscription.rb', line 8

def next_transaction_on
  @next_transaction_on
end

#objectObject (readonly)

Returns the value of attribute object.



4
5
6
# File 'lib/paid/subscription.rb', line 4

def object
  @object
end

#planObject

Returns the value of attribute plan.



9
10
11
# File 'lib/paid/subscription.rb', line 9

def plan
  @plan
end

#started_atObject

Returns the value of attribute started_at.



11
12
13
# File 'lib/paid/subscription.rb', line 11

def started_at
  @started_at
end

#starts_onObject

Returns the value of attribute starts_on.



6
7
8
# File 'lib/paid/subscription.rb', line 6

def starts_on
  @starts_on
end

Class Method Details

.all(params = {}, headers = {}) ⇒ Object



15
16
17
18
# File 'lib/paid/subscription.rb', line 15

def self.all(params={}, headers={})
  method = APIMethod.new(:get, "/subscriptions", params, headers, self)
  APIList.new(self, method.execute, method)
end

.create(params = {}, headers = {}) ⇒ Object



28
29
30
31
# File 'lib/paid/subscription.rb', line 28

def self.create(params={}, headers={})
  method = APIMethod.new(:post, "/subscriptions", params, headers, self)
  self.new(method.execute, method)
end

.retrieve(id, params = {}, headers = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/paid/subscription.rb', line 20

def self.retrieve(id, params={}, headers={})
  params = ParamsBuilder.merge(params, {
    :id => id
  })
  method = APIMethod.new(:get, "/subscriptions/:id", params, headers, self)
  self.new(method.execute, method)
end

Instance Method Details

#cancel(params = {}, headers = {}) ⇒ Object



38
39
40
41
# File 'lib/paid/subscription.rb', line 38

def cancel(params={}, headers={})
  method = APIMethod.new(:post, "/subscriptions/:id/cancel", params, headers, self)
  self.refresh_from(method.execute, method)
end

#refresh(params = {}, headers = {}) ⇒ Object



33
34
35
36
# File 'lib/paid/subscription.rb', line 33

def refresh(params={}, headers={})
  method = APIMethod.new(:get, "/subscriptions/:id", params, headers, self)
  self.refresh_from(method.execute, method)
end