Class: Stripe::Customer

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::NestedResource
Includes:
APIOperations::Delete, APIOperations::Save
Defined in:
lib/stripe/resources/customer.rb

Constant Summary collapse

OBJECT_NAME =
"customer".freeze

Instance Attribute Summary

Attributes inherited from APIResource

#save_with_parent

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::NestedResource

nested_resource_class_methods

Methods included from APIOperations::Save

included, #save

Methods included from APIOperations::Delete

#delete, included

Methods inherited from APIResource

class_name, custom_method, #refresh, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #refresh_from, serialize_params, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Method Details

#add_invoice_item(params, opts = {}) ⇒ Object



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

def add_invoice_item(params, opts = {})
  opts = @opts.merge(Util.normalize_opts(opts))
  InvoiceItem.create(params.merge(customer: id), opts)
end

#cancel_subscription(params = {}, opts = {}) ⇒ Object



60
61
62
63
64
# File 'lib/stripe/resources/customer.rb', line 60

def cancel_subscription(params = {}, opts = {})
  resp, opts = request(:delete, subscription_url, params, opts)
  initialize_from({ subscription: resp.data }, opts, true)
  subscription
end

#charges(params = {}, opts = {}) ⇒ Object



50
51
52
53
# File 'lib/stripe/resources/customer.rb', line 50

def charges(params = {}, opts = {})
  opts = @opts.merge(Util.normalize_opts(opts))
  Charge.all(params.merge(customer: id), opts)
end

#create_subscription(params = {}, opts = {}) ⇒ Object



72
73
74
75
76
# File 'lib/stripe/resources/customer.rb', line 72

def create_subscription(params = {}, opts = {})
  resp, opts = request(:post, subscriptions_url, params, opts)
  initialize_from({ subscription: resp.data }, opts, true)
  subscription
end

#create_upcoming_invoice(params = {}, opts = {}) ⇒ Object



55
56
57
58
# File 'lib/stripe/resources/customer.rb', line 55

def create_upcoming_invoice(params = {}, opts = {})
  opts = @opts.merge(Util.normalize_opts(opts))
  Invoice.create(params.merge(customer: id), opts)
end

#delete_discountObject



78
79
80
81
# File 'lib/stripe/resources/customer.rb', line 78

def delete_discount
  _, opts = request(:delete, discount_url)
  initialize_from({ discount: nil }, opts, true)
end

#invoice_items(params = {}, opts = {}) ⇒ Object



40
41
42
43
# File 'lib/stripe/resources/customer.rb', line 40

def invoice_items(params = {}, opts = {})
  opts = @opts.merge(Util.normalize_opts(opts))
  InvoiceItem.all(params.merge(customer: id), opts)
end

#invoices(params = {}, opts = {}) ⇒ Object



35
36
37
38
# File 'lib/stripe/resources/customer.rb', line 35

def invoices(params = {}, opts = {})
  opts = @opts.merge(Util.normalize_opts(opts))
  Invoice.all(params.merge(customer: id), opts)
end

#upcoming_invoice(params = {}, opts = {}) ⇒ Object



45
46
47
48
# File 'lib/stripe/resources/customer.rb', line 45

def upcoming_invoice(params = {}, opts = {})
  opts = @opts.merge(Util.normalize_opts(opts))
  Invoice.upcoming(params.merge(customer: id), opts)
end

#update_subscription(params = {}, opts = {}) ⇒ Object



66
67
68
69
70
# File 'lib/stripe/resources/customer.rb', line 66

def update_subscription(params = {}, opts = {})
  resp, opts = request(:post, subscription_url, params, opts)
  initialize_from({ subscription: resp.data }, opts, true)
  subscription
end