class Aptible::BillForward::Resource
Public Class Methods
all(query = {})
click to toggle source
# File lib/aptible/billforward/resource.rb, line 6 def self.all(query = {}) client.get collection_path, query: query end
basename()
click to toggle source
# File lib/aptible/billforward/resource.rb, line 31 def self.basename name.split('::').last.underscore.dasherize.pluralize end
by_subscription_id(subscription_id, options = {})
click to toggle source
# File lib/aptible/billforward/resource.rb, line 53 def self.by_subscription_id(subscription_id, options = {}) state = options[:active] ? '/active' : '' client.get( "#{collection_path}/#{subscription_id}#{state}", order: 'DESC', order_by: 'start' ) end
client()
click to toggle source
# File lib/aptible/billforward/resource.rb, line 35 def self.client @client ||= Aptible::BillForward::Client.new end
collection_path()
click to toggle source
# File lib/aptible/billforward/resource.rb, line 18 def self.collection_path basename end
create(params, query = {})
click to toggle source
# File lib/aptible/billforward/resource.rb, line 14 def self.create(params, query = {}) client.post collection_path, new(client.agent, params), query: query end
find(id)
click to toggle source
# File lib/aptible/billforward/resource.rb, line 10 def self.find(id) client.get("#{collection_path}/#{id}").first end
Public Instance Methods
client()
click to toggle source
# File lib/aptible/billforward/resource.rb, line 39 def client @client ||= Aptible::BillForward::Client.new end
href()
click to toggle source
# File lib/aptible/billforward/resource.rb, line 27 def href "#{self.class.collection_path}/#{id}" end
invoice()
click to toggle source
# File lib/aptible/billforward/resource.rb, line 43 def invoice return nil unless invoiceID Aptible::BillForward::Invoice.find(invoiceID) end
serialize()
click to toggle source
# File lib/aptible/billforward/resource.rb, line 61 def serialize type = self.class.basename.underscore.camelize(:lower).pluralize body = {} body[type] = [to_attrs] body end
subscription()
click to toggle source
# File lib/aptible/billforward/resource.rb, line 48 def subscription return nil unless subscriptionID Aptible::BillForward::Subscription.find(subscriptionID) end
update(params)
click to toggle source
# File lib/aptible/billforward/resource.rb, line 22 def update(params) self.attrs = attrs.merge(params) client.put href, self end