Class: Stripe::ProductFeatureService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/product_feature_service.rb

Instance Method Summary collapse

Methods inherited from StripeService

#initialize, #request, #request_stream

Constructor Details

This class inherits a constructor from Stripe::StripeService

Instance Method Details

#create(product, params = {}, opts = {}) ⇒ Object

Creates a product_feature, which represents a feature attachment to a product



7
8
9
10
11
12
13
14
15
# File 'lib/stripe/services/product_feature_service.rb', line 7

def create(product, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/products/%<product>s/features", { product: CGI.escape(product) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#delete(product, id, params = {}, opts = {}) ⇒ Object

Deletes the feature attachment to a product



18
19
20
21
22
23
24
25
26
# File 'lib/stripe/services/product_feature_service.rb', line 18

def delete(product, id, params = {}, opts = {})
  request(
    method: :delete,
    path: format("/v1/products/%<product>s/features/%<id>s", { product: CGI.escape(product), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#list(product, params = {}, opts = {}) ⇒ Object

Retrieve a list of features for a product



29
30
31
32
33
34
35
36
37
# File 'lib/stripe/services/product_feature_service.rb', line 29

def list(product, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/products/%<product>s/features", { product: CGI.escape(product) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#retrieve(product, id, params = {}, opts = {}) ⇒ Object

Retrieves a product_feature, which represents a feature attachment to a product



40
41
42
43
44
45
46
47
48
# File 'lib/stripe/services/product_feature_service.rb', line 40

def retrieve(product, id, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/products/%<product>s/features/%<id>s", { product: CGI.escape(product), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#serialize_batch_create(product, params = {}, opts = {}) ⇒ Object

Serializes a ProductFeature create request into a batch job JSONL line.



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/stripe/services/product_feature_service.rb', line 51

def serialize_batch_create(product, 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] = { product: product }
  request_body[:context] = opts[:stripe_context] if opts[:stripe_context]
  JSON.generate(request_body)
end

#serialize_batch_delete(product, id, params = {}, opts = {}) ⇒ Object

Serializes a ProductFeature delete request into a batch job JSONL line.



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/stripe/services/product_feature_service.rb', line 66

def serialize_batch_delete(product, id, 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] = { product: product, id: id }
  request_body[:context] = opts[:stripe_context] if opts[:stripe_context]
  JSON.generate(request_body)
end