Class: Pago::V2026_04::Services::CustomerPortal::BenefitGrants

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

#get(id) ⇒ Object

Get a benefit grant by ID for the authenticated customer.

Scopes: customer_portal:read customer_portal:write

Parameters:

  • id (String)

    The benefit grant ID.

Returns:

  • (Object)

Raises:



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 93

def get(id)
  data = client.request(
    http_method: "GET",
    path: "/v1/customer-portal/benefit-grants/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Unions::CustomerBenefitGrant.from_json(data)
end

#list(query: nil, type: nil, benefit_id: nil, checkout_id: nil, order_id: nil, subscription_id: nil, member_id: nil, page: 1, limit: 10, sorting: ["product_benefit", "-granted_at"]) ⇒ Models::ListResourceCustomerBenefitGrant

List benefits grants of the authenticated customer.

Scopes: customer_portal:read customer_portal:write

Parameters:

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

    Filter by benefit description.

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

    Filter by benefit type.

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

    Filter by benefit ID.

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

    Filter by checkout ID.

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

    Filter by order ID.

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

    Filter by subscription ID.

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

    Filter by member ID.

  • 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: ["product_benefit", "-granted_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.

  • query: (String, nil) (defaults to: nil)
  • type: (Object) (defaults to: nil)
  • benefit_id: (Object) (defaults to: nil)
  • checkout_id: (Object) (defaults to: nil)
  • order_id: (Object) (defaults to: nil)
  • subscription_id: (Object) (defaults to: nil)
  • member_id: (Object) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["product_benefit", "-granted_at"])

Returns:

Raises:



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 61

def list(query: nil, type: nil, benefit_id: nil, checkout_id: nil, order_id: nil, subscription_id: nil, member_id: nil, page: 1, limit: 10, sorting: ["product_benefit", "-granted_at"])
  data = client.request(
    http_method: "GET",
    path: "/v1/customer-portal/benefit-grants/",
    path_params: {},
    query: { "query" => query, "type" => type, "benefit_id" => benefit_id, "checkout_id" => checkout_id, "order_id" => order_id, "subscription_id" => subscription_id, "member_id" => member_id, "page" => page, "limit" => limit, "sorting" => sorting },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::ListResourceCustomerBenefitGrant.from_json(data)
end

#list_each(query: nil, type: nil, benefit_id: nil, checkout_id: nil, order_id: nil, subscription_id: nil, member_id: nil, limit: 10, sorting: ["product_benefit", "-granted_at"]) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list, fetching pages on demand.

Parameters:

  • query: (String, nil) (defaults to: nil)
  • type: (Object) (defaults to: nil)
  • benefit_id: (Object) (defaults to: nil)
  • checkout_id: (Object) (defaults to: nil)
  • order_id: (Object) (defaults to: nil)
  • subscription_id: (Object) (defaults to: nil)
  • member_id: (Object) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["product_benefit", "-granted_at"])

Yield Parameters:

  • item (Object)

Returns:



77
78
79
80
81
82
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 77

def list_each(query: nil, type: nil, benefit_id: nil, checkout_id: nil, order_id: nil, subscription_id: nil, member_id: nil, limit: 10, sorting: ["product_benefit", "-granted_at"], &block)
  paginator = ::Pago::Paginator.new do |page_number|
    list(query: query, type: type, benefit_id: benefit_id, checkout_id: checkout_id, order_id: order_id, subscription_id: subscription_id, member_id: member_id, page: page_number, limit: limit, sorting: sorting)
  end
  block ? paginator.each(&block) : paginator
end

#update(id, body: {}) ⇒ Object

Update a benefit grant for the authenticated customer.

Scopes: customer_portal:write

Parameters:

  • id (String)

    The benefit grant ID.

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

    the request body.

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

Returns:

  • (Object)

Raises:



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 116

def update(id, body: {})
  data = client.request(
    http_method: "PATCH",
    path: "/v1/customer-portal/benefit-grants/{id}",
    path_params: { "id" => id },
    query: {},
    body: body,
    response_type: :json,
    errors: { 403 => Errors::NotPermitted, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Unions::CustomerBenefitGrant.from_json(data)
end