Class: Stripe::Margin
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Margin
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/margin.rb
Overview
A (partner) margin represents a specific discount distributed in partner reseller programs to business partners who resell products and services and earn a discount (margin) for doing so.
Constant Summary collapse
- OBJECT_NAME =
"margin"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Whether the margin can be applied to invoices, invoice items, or invoice line items.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#livemode ⇒ Object
readonly
If the object exists in live mode, the value is ‘true`.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](docs.stripe.com/api/metadata) that you can attach to an object.
-
#name ⇒ Object
readonly
Name of the margin that’s displayed on, for example, invoices.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#percent_off ⇒ Object
readonly
Percent that will be taken off the subtotal before tax (after all other discounts and promotions) of any invoice to which the margin is applied.
-
#updated ⇒ Object
readonly
Time at which the object was last updated.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Create a margin object to be used with invoices, invoice items, and invoice line items for a customer to represent a partner discount.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.list(params = {}, opts = {}) ⇒ Object
Retrieve a list of your margins.
- .object_name ⇒ Object
-
.update(margin, params = {}, opts = {}) ⇒ Object
Update the specified margin object.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::Save
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #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 Attribute Details
#active ⇒ Object (readonly)
Whether the margin can be applied to invoices, invoice items, or invoice line items. Defaults to ‘true`.
18 19 20 |
# File 'lib/stripe/resources/margin.rb', line 18 def active @active end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
20 21 22 |
# File 'lib/stripe/resources/margin.rb', line 20 def created @created end |
#id ⇒ Object (readonly)
Unique identifier for the object.
22 23 24 |
# File 'lib/stripe/resources/margin.rb', line 22 def id @id end |
#livemode ⇒ Object (readonly)
If the object exists in live mode, the value is ‘true`. If the object exists in test mode, the value is `false`.
24 25 26 |
# File 'lib/stripe/resources/margin.rb', line 24 def livemode @livemode end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
26 27 28 |
# File 'lib/stripe/resources/margin.rb', line 26 def @metadata end |
#name ⇒ Object (readonly)
Name of the margin that’s displayed on, for example, invoices.
28 29 30 |
# File 'lib/stripe/resources/margin.rb', line 28 def name @name end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
30 31 32 |
# File 'lib/stripe/resources/margin.rb', line 30 def object @object end |
#percent_off ⇒ Object (readonly)
Percent that will be taken off the subtotal before tax (after all other discounts and promotions) of any invoice to which the margin is applied.
32 33 34 |
# File 'lib/stripe/resources/margin.rb', line 32 def percent_off @percent_off end |
#updated ⇒ Object (readonly)
Time at which the object was last updated. Measured in seconds since the Unix epoch.
34 35 36 |
# File 'lib/stripe/resources/margin.rb', line 34 def updated @updated end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Create a margin object to be used with invoices, invoice items, and invoice line items for a customer to represent a partner discount. A margin has a percent_off which is the percent that will be taken off the subtotal after all items and other discounts and promotions) of any invoices for a customer. Calculation of prorations do not include any partner margins applied on the original invoice item.
37 38 39 |
# File 'lib/stripe/resources/margin.rb', line 37 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/billing/margins", params: params, opts: opts) end |
.field_remappings ⇒ Object
60 61 62 |
# File 'lib/stripe/resources/margin.rb', line 60 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
56 57 58 |
# File 'lib/stripe/resources/margin.rb', line 56 def self.inner_class_types @inner_class_types = {} end |
.list(params = {}, opts = {}) ⇒ Object
Retrieve a list of your margins.
42 43 44 |
# File 'lib/stripe/resources/margin.rb', line 42 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/billing/margins", params: params, opts: opts) end |
.object_name ⇒ Object
13 14 15 |
# File 'lib/stripe/resources/margin.rb', line 13 def self.object_name "margin" end |
.update(margin, params = {}, opts = {}) ⇒ Object
Update the specified margin object. Certain fields of the margin object are not editable.
47 48 49 50 51 52 53 54 |
# File 'lib/stripe/resources/margin.rb', line 47 def self.update(margin, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/billing/margins/%<margin>s", { margin: CGI.escape(margin) }), params: params, opts: opts ) end |