Class: Pago::V2026_04::Services::CustomerPortal::Subscriptions
- Defined in:
- lib/pago/v2026_04/services/customer_portal.rb,
sig/pago/v2026_04/generated.rbs
Instance Attribute Summary
Attributes inherited from Service
Instance Method Summary collapse
-
#cancel(id) ⇒ Models::CustomerSubscription
Cancel a subscription of the authenticated customer.
-
#get(id) ⇒ Models::CustomerSubscription
Get a subscription for the authenticated customer.
-
#list(product_id: nil, active: nil, query: nil, page: 1, limit: 10, sorting: ["-started_at"]) ⇒ Models::ListResourceCustomerSubscription
List subscriptions of the authenticated customer.
-
#list_each(product_id: nil, active: nil, query: nil, limit: 10, sorting: ["-started_at"]) {|item| ... } ⇒ Pago::Paginator
Enumerate every item of
list, fetching pages on demand. -
#update(id, body: {}) ⇒ Models::CustomerSubscription
Update a subscription of the authenticated customer.
Methods inherited from Service
Constructor Details
This class inherits a constructor from Pago::Service
Instance Method Details
#cancel(id) ⇒ Models::CustomerSubscription
Cancel a subscription of the authenticated customer.
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 |
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 1087 def cancel(id) data = client.request( http_method: "DELETE", path: "/v1/customer-portal/subscriptions/{id}", path_params: { "id" => id }, query: {}, response_type: :json, errors: { 403 => Errors::AlreadyCanceledSubscription, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError } ) Models::CustomerSubscription.from_json(data) end |
#get(id) ⇒ Models::CustomerSubscription
Get a subscription for the authenticated customer.
Scopes: customer_portal:read customer_portal:write
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 |
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 1067 def get(id) data = client.request( http_method: "GET", path: "/v1/customer-portal/subscriptions/{id}", path_params: { "id" => id }, query: {}, response_type: :json, errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError } ) Models::CustomerSubscription.from_json(data) end |
#list(product_id: nil, active: nil, query: nil, page: 1, limit: 10, sorting: ["-started_at"]) ⇒ Models::ListResourceCustomerSubscription
List subscriptions of the authenticated customer.
Scopes: customer_portal:read customer_portal:write
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 1035 def list(product_id: nil, active: nil, query: nil, page: 1, limit: 10, sorting: ["-started_at"]) data = client.request( http_method: "GET", path: "/v1/customer-portal/subscriptions/", path_params: {}, query: { "product_id" => product_id, "active" => active, "query" => query, "page" => page, "limit" => limit, "sorting" => sorting }, response_type: :json, errors: { 422 => Errors::HTTPValidationError } ) Models::ListResourceCustomerSubscription.from_json(data) end |
#list_each(product_id: nil, active: nil, query: nil, limit: 10, sorting: ["-started_at"]) {|item| ... } ⇒ Pago::Paginator
Enumerate every item of list, fetching pages on demand.
1051 1052 1053 1054 1055 1056 |
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 1051 def list_each(product_id: nil, active: nil, query: nil, limit: 10, sorting: ["-started_at"], &block) paginator = ::Pago::Paginator.new do |page_number| list(product_id: product_id, active: active, query: query, page: page_number, limit: limit, sorting: sorting) end block ? paginator.each(&block) : paginator end |
#update(id, body: {}) ⇒ Models::CustomerSubscription
Update a subscription of the authenticated customer.
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 |
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 1109 def update(id, body: {}) data = client.request( http_method: "PATCH", path: "/v1/customer-portal/subscriptions/{id}", path_params: { "id" => id }, query: {}, body: body, response_type: :json, errors: { 402 => Errors::PaymentFailed, 403 => Errors::Update403Error, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError } ) Models::CustomerSubscription.from_json(data) end |