Class: Datmachine::Customer

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/datmachine/resources/customer.rb

Overview

A customer represents a business or person within your Marketplace. A customer can have many funding instruments such as cards and bank accounts associated to them.

Instance Attribute Summary

Attributes included from Resource

#attributes, #href, #hyperlinks, #id, #links

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

#copy_from, #does_resource_respond_to?, #fetch, #hydrate, included, #initialize, #method_missing, #reload, #respond_to?, #respond_to_missing?, #sanitize, #save, #unstore

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Datmachine::Resource

Class Method Details

.find_by_id(id) ⇒ Object



31
32
33
# File 'lib/datmachine/resources/customer.rb', line 31

def self.find_by_id(id)
   Datmachine::Customer.fetch("/customers/#{id}")
end

Instance Method Details

#all_subscriptionsObject



23
24
25
# File 'lib/datmachine/resources/customer.rb', line 23

def all_subscriptions 
  subscriptions.to_a
end

#create_subscription(options = {}) ⇒ Object



10
11
12
13
14
# File 'lib/datmachine/resources/customer.rb', line 10

def create_subscription(options = {})
  options[:href] =  self.subscriptions.href
  subscription = Datmachine::Subscription.new(options)
  subscription.save
end

#last_subscriptionObject



27
28
29
# File 'lib/datmachine/resources/customer.rb', line 27

def last_subscription
  all_subscriptions.last
end

#update(options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/datmachine/resources/customer.rb', line 16

def update(options = {})
  options.each do |key, value|
    attributes[key] = value
  end
  save 
end