Class: Stripe::PriceService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::PriceService
- Defined in:
- lib/stripe/services/price_service.rb
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Object
Creates a new [Price for an existing <a href=“docs.stripe.com/api/products”>Product](docs.stripe.com/api/prices).
-
#list(params = {}, opts = {}) ⇒ Object
Returns a list of your active prices, excluding [inline prices](docs.stripe.com/docs/products-prices/pricing-models#inline-pricing).
-
#retrieve(price, params = {}, opts = {}) ⇒ Object
Retrieves the price with the given ID.
-
#search(params = {}, opts = {}) ⇒ Object
Search for prices you’ve previously created using Stripe’s [Search Query Language](docs.stripe.com/docs/search#search-query-language).
-
#serialize_batch_create(params = {}, opts = {}) ⇒ Object
Serializes a Price create request into a batch job JSONL line.
-
#serialize_batch_update(price, params = {}, opts = {}) ⇒ Object
Serializes a Price update request into a batch job JSONL line.
-
#update(price, params = {}, opts = {}) ⇒ Object
Updates the specified price by setting the values of the parameters passed.
Methods inherited from StripeService
#initialize, #request, #request_stream
Constructor Details
This class inherits a constructor from Stripe::StripeService
Instance Method Details
#create(params = {}, opts = {}) ⇒ Object
Creates a new [Price for an existing <a href=“docs.stripe.com/api/products”>Product](docs.stripe.com/api/prices). The Price can be recurring or one-time.
7 8 9 10 11 |
# File 'lib/stripe/services/price_service.rb', line 7 def create(params = {}, opts = {}) params = ::Stripe::PriceCreateParams.coerce_params(params) unless params.is_a?(Stripe::RequestParams) request(method: :post, path: "/v1/prices", params: params, opts: opts, base_address: :api) end |
#list(params = {}, opts = {}) ⇒ Object
Returns a list of your active prices, excluding [inline prices](docs.stripe.com/docs/products-prices/pricing-models#inline-pricing). For the list of inactive prices, set active to false.
14 15 16 |
# File 'lib/stripe/services/price_service.rb', line 14 def list(params = {}, opts = {}) request(method: :get, path: "/v1/prices", params: params, opts: opts, base_address: :api) end |
#retrieve(price, params = {}, opts = {}) ⇒ Object
Retrieves the price with the given ID.
19 20 21 22 23 24 25 26 27 |
# File 'lib/stripe/services/price_service.rb', line 19 def retrieve(price, params = {}, opts = {}) request( method: :get, path: format("/v1/prices/%<price>s", { price: CGI.escape(price) }), params: params, opts: opts, base_address: :api ) end |
#search(params = {}, opts = {}) ⇒ Object
Search for prices you’ve previously created using Stripe’s [Search Query Language](docs.stripe.com/docs/search#search-query-language). Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
33 34 35 36 37 38 39 40 41 |
# File 'lib/stripe/services/price_service.rb', line 33 def search(params = {}, opts = {}) request( method: :get, path: "/v1/prices/search", params: params, opts: opts, base_address: :api ) end |
#serialize_batch_create(params = {}, opts = {}) ⇒ Object
Serializes a Price create request into a batch job JSONL line.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/stripe/services/price_service.rb', line 44 def serialize_batch_create(params = {}, opts = {}) request_id = SecureRandom.uuid stripe_version = opts[:stripe_version] || Stripe.api_version request_body = { id: request_id, params: params, stripe_version: stripe_version, } request_body[:context] = opts[:stripe_context] if opts[:stripe_context] JSON.generate(request_body) end |
#serialize_batch_update(price, params = {}, opts = {}) ⇒ Object
Serializes a Price update request into a batch job JSONL line.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/stripe/services/price_service.rb', line 58 def serialize_batch_update(price, params = {}, opts = {}) request_id = SecureRandom.uuid stripe_version = opts[:stripe_version] || Stripe.api_version request_body = { id: request_id, params: params, stripe_version: stripe_version, } request_body[:path_params] = { price: price } request_body[:context] = opts[:stripe_context] if opts[:stripe_context] JSON.generate(request_body) end |
#update(price, params = {}, opts = {}) ⇒ Object
Updates the specified price by setting the values of the parameters passed. Any parameters not provided are left unchanged.
73 74 75 76 77 78 79 80 81 |
# File 'lib/stripe/services/price_service.rb', line 73 def update(price, params = {}, opts = {}) request( method: :post, path: format("/v1/prices/%<price>s", { price: CGI.escape(price) }), params: params, opts: opts, base_address: :api ) end |