Class: Stripe::ProductService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::ProductService
- Defined in:
- lib/stripe/services/product_service.rb
Defined Under Namespace
Classes: CreateParams, DeleteParams, ListParams, RetrieveParams, SearchParams, UpdateParams
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Object
Creates a new product object.
-
#delete(id, params = {}, opts = {}) ⇒ Object
Delete a product.
-
#initialize(requestor) ⇒ ProductService
constructor
A new instance of ProductService.
-
#list(params = {}, opts = {}) ⇒ Object
Returns a list of your products.
-
#retrieve(id, params = {}, opts = {}) ⇒ Object
Retrieves the details of an existing product.
-
#search(params = {}, opts = {}) ⇒ Object
Search for products you’ve previously created using Stripe’s [Search Query Language](stripe.com/docs/search#search-query-language).
-
#update(id, params = {}, opts = {}) ⇒ Object
Updates the specific product by setting the values of the parameters passed.
Methods inherited from StripeService
Constructor Details
#initialize(requestor) ⇒ ProductService
Returns a new instance of ProductService.
8 9 10 11 |
# File 'lib/stripe/services/product_service.rb', line 8 def initialize(requestor) super(requestor) @features = Stripe::ProductFeatureService.new(@requestor) end |
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
6 7 8 |
# File 'lib/stripe/services/product_service.rb', line 6 def features @features end |
Instance Method Details
#create(params = {}, opts = {}) ⇒ Object
Creates a new product object.
439 440 441 |
# File 'lib/stripe/services/product_service.rb', line 439 def create(params = {}, opts = {}) request(method: :post, path: "/v1/products", params: params, opts: opts, base_address: :api) end |
#delete(id, params = {}, opts = {}) ⇒ Object
Delete a product. Deleting a product is only possible if it has no prices associated with it. Additionally, deleting a product with type=good is only possible if it has no SKUs associated with it.
444 445 446 447 448 449 450 451 452 |
# File 'lib/stripe/services/product_service.rb', line 444 def delete(id, params = {}, opts = {}) request( method: :delete, path: format("/v1/products/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts, base_address: :api ) end |
#list(params = {}, opts = {}) ⇒ Object
Returns a list of your products. The products are returned sorted by creation date, with the most recently created products appearing first.
455 456 457 |
# File 'lib/stripe/services/product_service.rb', line 455 def list(params = {}, opts = {}) request(method: :get, path: "/v1/products", params: params, opts: opts, base_address: :api) end |
#retrieve(id, params = {}, opts = {}) ⇒ Object
Retrieves the details of an existing product. Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information.
460 461 462 463 464 465 466 467 468 |
# File 'lib/stripe/services/product_service.rb', line 460 def retrieve(id, params = {}, opts = {}) request( method: :get, path: format("/v1/products/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts, base_address: :api ) end |
#search(params = {}, opts = {}) ⇒ Object
Search for products you’ve previously created using Stripe’s [Search Query Language](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.
474 475 476 477 478 479 480 481 482 |
# File 'lib/stripe/services/product_service.rb', line 474 def search(params = {}, opts = {}) request( method: :get, path: "/v1/products/search", params: params, opts: opts, base_address: :api ) end |
#update(id, params = {}, opts = {}) ⇒ Object
Updates the specific product by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
485 486 487 488 489 490 491 492 493 |
# File 'lib/stripe/services/product_service.rb', line 485 def update(id, params = {}, opts = {}) request( method: :post, path: format("/v1/products/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts, base_address: :api ) end |