Module: Stripe::APIOperations::Save
- Extended by:
- Gem::Deprecate
- Included in:
- Stripe::Account, Stripe::AlipayAccount, Stripe::ApplicationFeeRefund, BankAccount, Billing::CreditGrant, Billing::Meter, BillingPortal::Configuration, Capability, Card, Charge, Checkout::Session, Climate::Order, Coupon, CreditNote, Customer, CustomerBalanceTransaction, Dispute, Entitlements::Feature, FileLink, Identity::VerificationSession, Invoice, InvoiceItem, InvoiceLineItem, Issuing::Authorization, Issuing::Card, Issuing::Cardholder, Issuing::Dispute, Issuing::PersonalizationDesign, Issuing::Token, Issuing::Transaction, PaymentIntent, PaymentLink, PaymentMethod, PaymentMethodConfiguration, PaymentMethodDomain, Payout, Person, Plan, Price, Product, PromotionCode, Quote, Radar::ValueList, Refund, Reversal, SetupIntent, ShippingRate, Source, Subscription, SubscriptionItem, SubscriptionSchedule, Tax::Registration, TaxRate, Terminal::Configuration, Terminal::Location, Terminal::Reader, Topup, Transfer, Treasury::FinancialAccount, WebhookEndpoint
- Defined in:
- lib/stripe/api_operations/save.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#save(params = {}, opts = {}) ⇒ Object
The ‘save` method is DEPRECATED and will be removed in a future major version of the library.
Class Method Details
.included(base) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/stripe/api_operations/save.rb', line 78 def self.included(base) # Set `metadata` as additive so that when it's set directly we remember # to clear keys that may have been previously set by sending empty # values for them. # # It's possible that not every object with `Save` has `metadata`, but # it's a close enough heuristic, and having this option set when there # is no `metadata` field is not harmful. base.additive_object_param(:metadata) base.extend(ClassMethods) end |
Instance Method Details
#save(params = {}, opts = {}) ⇒ Object
The ‘save` method is DEPRECATED and will be removed in a future major version of the library. Use the `update` method on the resource instead.
Creates or updates an API resource.
If the resource doesn’t yet have an assigned ID and the resource is one that can be created, then the method attempts to create the resource. The resource is updated otherwise.
Attributes
-
params
- Overrides any parameters in the resource’s serialized data and includes them in the create or update. If:req_url:
is included in the list, it overrides the update URL used for the create or update. -
opts
- A Hash of additional options (separate from the params / object values) to be added to the request. E.g. to allow for an idempotency_key to be passed in the request headers, or for the api_key to be overwritten. See APIOperations::Request.execute_resource_request.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/stripe/api_operations/save.rb', line 54 def save(params = {}, opts = {}) # We started unintentionally (sort of) allowing attributes sent to # +save+ to override values used during the update. So as not to break # the API, this makes that official here. update_attributes(params) # Now remove any parameters that look like object attributes. params = params.reject { |k, _| respond_to?(k) } values = serialize_params(self).merge(params) # Please note that id gets removed here our call to #url above has already # generated a uri for this object with an identifier baked in values.delete(:id) opts = Util.normalize_opts(opts) APIRequestor.active_requestor.execute_request_initialize_from(:post, save_url, :api, self, params: values, opts: opts, usage: ["save"]) end |