Class: Stripe::ProductCatalog::TrialOffer

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

Overview

Trial offers let you define free or paid introductory pricing for a subscription item. A TrialOffer specifies the price to charge during the trial, how many billing intervals the trial lasts, and what price the subscription item transitions to when the trial ends. You attach a TrialOffer to a subscription item using items[current_trial][trial_offer] when creating or updating a subscription.

Defined Under Namespace

Classes: Duration, EndBehavior

Constant Summary collapse

OBJECT_NAME =
"product_catalog.trial_offer"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #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

included

Methods inherited from StripeObject

#==, #[], #[]=, #_get_inner_class_type, #_get_union_variant_class, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #hash, #initialize, inner_class_union_variant_types, #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 trial offer is active. Set to false to archive the trial offer.



75
76
77
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 75

def active
  @active
end

#duration ⇒ Object (readonly)

Attribute for field duration



77
78
79
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 77

def duration
  @duration
end

#end_behavior ⇒ Object (readonly)

Attribute for field end_behavior



79
80
81
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 79

def end_behavior
  @end_behavior
end

#id ⇒ Object (readonly)

Unique identifier for the object.



81
82
83
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 81

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.



83
84
85
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 83

def livemode
  @livemode
end

#nickname ⇒ Object (readonly)

A brief description of the trial offer, hidden from customers.



85
86
87
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 85

def nickname
  @nickname
end

#object ⇒ Object (readonly)

String representing the object's type. Objects of the same type share the same value.



87
88
89
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 87

def object
  @object
end

#price ⇒ Object (readonly)

The price during the trial offer.



89
90
91
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 89

def price
  @price
end

Class Method Details

.create(params = {}, opts = {}) ⇒ Object

Creates a trial offer.



92
93
94
95
96
97
98
99
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 92

def self.create(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: "/v1/product_catalog/trial_offers",
    params: params,
    opts: opts
  )
end

.field_remappings ⇒ Object



125
126
127
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 125

def self.field_remappings
  @field_remappings = {}
end

.inner_class_types ⇒ Object



121
122
123
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 121

def self.inner_class_types
  @inner_class_types = { duration: Duration, end_behavior: EndBehavior }
end

.list(params = {}, opts = {}) ⇒ Object

Returns a list of trial offers.



102
103
104
105
106
107
108
109
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 102

def self.list(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: "/v1/product_catalog/trial_offers",
    params: params,
    opts: opts
  )
end

.object_name ⇒ Object



17
18
19
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 17

def self.object_name
  "product_catalog.trial_offer"
end

.update(id, params = {}, opts = {}) ⇒ Object

Updates the specified trial offer by setting the values of the parameters passed. Any parameters not provided are left unchanged.



112
113
114
115
116
117
118
119
# File 'lib/stripe/resources/product_catalog/trial_offer.rb', line 112

def self.update(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/product_catalog/trial_offers/%<id>s", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end