Class: Apruve::SubscriptionAdjustment

Inherits:
ApruveObject show all
Defined in:
lib/apruve/resources/subscription_adjustment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApruveObject

#initialize, logger, #logger, #to_hash, #to_json, #validate

Constructor Details

This class inherits a constructor from Apruve::ApruveObject

Instance Attribute Details

#amount_centsObject

Returns the value of attribute amount_cents.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def amount_cents
  @amount_cents
end

#api_urlObject

Returns the value of attribute api_url.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def api_url
  @api_url
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def description
  @description
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def id
  @id
end

#merchant_notesObject

Returns the value of attribute merchant_notes.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def merchant_notes
  @merchant_notes
end

#price_ea_centsObject

Returns the value of attribute price_ea_cents.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def price_ea_cents
  @price_ea_cents
end

#quantityObject

Returns the value of attribute quantity.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def quantity
  @quantity
end

#skuObject

Returns the value of attribute sku.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def sku
  @sku
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def status
  @status
end

#subscription_idObject

Returns the value of attribute subscription_id.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def subscription_id
  @subscription_id
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def title
  @title
end

#variant_infoObject

Returns the value of attribute variant_info.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def variant_info
  @variant_info
end

#vendorObject

Returns the value of attribute vendor.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def vendor
  @vendor
end

#view_product_urlObject

Returns the value of attribute view_product_url.



3
4
5
# File 'lib/apruve/resources/subscription_adjustment.rb', line 3

def view_product_url
  @view_product_url
end

Class Method Details

.delete(subscription_id, id) ⇒ Object



14
15
16
17
18
# File 'lib/apruve/resources/subscription_adjustment.rb', line 14

def self.delete(subscription_id, id)
  response = Apruve.delete("subscriptions/#{subscription_id}/adjustments/#{id}")
  logger.debug response.body
  nil
end

.find(subscription_id, id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/apruve/resources/subscription_adjustment.rb', line 6

def self.find(subscription_id, id)
  response = Apruve.get("subscriptions/#{subscription_id}/adjustments/#{id}")
  logger.debug response.body
  found = SubscriptionAdjustment.new(response.body)
  found.subscription_id = subscription_id
  found
end

.find_all(subscription_id) ⇒ Object



20
21
22
23
24
# File 'lib/apruve/resources/subscription_adjustment.rb', line 20

def self.find_all(subscription_id)
  response = Apruve.get("subscriptions/#{subscription_id}/adjustments")
  logger.debug response.body
  SubscriptionAdjustment.new(response.body)
end

Instance Method Details

#delete!Object



35
36
37
38
39
40
41
# File 'lib/apruve/resources/subscription_adjustment.rb', line 35

def delete!
  if self.id == nil
    raise 'SubscriptionAdjustment has not been saved'
  else
    SubscriptionAdjustment.delete self.subscription_id, self.id
  end
end

#save!Object



26
27
28
29
30
31
32
33
# File 'lib/apruve/resources/subscription_adjustment.rb', line 26

def save!
  validate
  response = Apruve.post("subscriptions/#{self.subscription_id}/adjustments", self.to_json)
  self.id = response.body['id']
  self.status = response.body['status']
  self.api_url = response.body['api_url']
  self.status
end