Class: Pago::V2026_04::Services::CustomerPortal::Subscriptions

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/customer_portal.rb,
sig/pago/v2026_04/generated.rbs

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Pago::Service

Instance Method Details

#cancel(id) ⇒ Models::CustomerSubscription

Cancel a subscription of the authenticated customer.

Parameters:

  • id (String)

    The subscription ID.

Returns:

Raises:



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

Parameters:

  • id (String)

    The subscription ID.

Returns:

Raises:



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

Parameters:

  • product_id (String, Array<String>, nil) (defaults to: nil)

    Filter by product ID.

  • active (Boolean, nil) (defaults to: nil)

    Filter by active or cancelled subscription.

  • query (String, nil) (defaults to: nil)

    Search by product or organization name.

  • page (Integer) (defaults to: 1)

    Page number, defaults to 1.

  • limit (Integer) (defaults to: 10)

    Size of a page, defaults to 10. Maximum is 100.

  • sorting (Array<String>, nil) (defaults to: ["-started_at"])

    Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order.

  • product_id: (Object) (defaults to: nil)
  • active: (Boolean, nil) (defaults to: nil)
  • query: (String, nil) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["-started_at"])

Returns:

Raises:



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.

Parameters:

  • product_id: (Object) (defaults to: nil)
  • active: (Boolean, nil) (defaults to: nil)
  • query: (String, nil) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["-started_at"])

Yield Parameters:

Returns:



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.

Parameters:

  • id (String)

    The subscription ID.

  • body (Hash, Object) (defaults to: {})

    the request body.

  • body: (Object) (defaults to: {})

Returns:

Raises:



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