Class: Dodopayments::Resources::Entitlements::Grants
- Inherits:
-
Object
- Object
- Dodopayments::Resources::Entitlements::Grants
- Defined in:
- lib/dodopayments/resources/entitlements/grants.rb
Instance Method Summary collapse
-
#fulfill_license_key(grant_id, key:, activations_limit: nil, expires_at: nil, request_options: {}) ⇒ Dodopayments::Models::Entitlements::EntitlementGrant
Some parameter documentations has been truncated, see Models::Entitlements::GrantFulfillLicenseKeyParams for more details.
-
#initialize(client:) ⇒ Grants
constructor
private
A new instance of Grants.
-
#list(id, customer_id: nil, page_number: nil, page_size: nil, status: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::Entitlements::EntitlementGrant>
GET /entitlements/id/grants (public API).
-
#revoke(grant_id, id:, request_options: {}) ⇒ Dodopayments::Models::Entitlements::EntitlementGrant
Revoke a single grant.
Constructor Details
#initialize(client:) ⇒ Grants
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Grants.
105 106 107 |
# File 'lib/dodopayments/resources/entitlements/grants.rb', line 105 def initialize(client:) @client = client end |
Instance Method Details
#fulfill_license_key(grant_id, key:, activations_limit: nil, expires_at: nil, request_options: {}) ⇒ Dodopayments::Models::Entitlements::EntitlementGrant
Some parameter documentations has been truncated, see Models::Entitlements::GrantFulfillLicenseKeyParams for more details.
For entitlements whose license-key config uses ‘manual` fulfillment, grants are created in the `pending` state without a key. Call this endpoint to deliver the key: the grant moves to `delivered`, the customer is emailed the key, and the `license_key.created` and `entitlement_grant.delivered` webhook events are sent.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/dodopayments/resources/entitlements/grants.rb', line 63 def fulfill_license_key(grant_id, params) parsed, = Dodopayments::Entitlements::GrantFulfillLicenseKeyParams.dump_request(params) @client.request( method: :post, path: ["grants/%1$s/license-key", grant_id], body: parsed, model: Dodopayments::Entitlements::EntitlementGrant, options: ) end |
#list(id, customer_id: nil, page_number: nil, page_size: nil, status: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::Entitlements::EntitlementGrant>
GET /entitlements/id/grants (public API)
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dodopayments/resources/entitlements/grants.rb', line 26 def list(id, params = {}) parsed, = Dodopayments::Entitlements::GrantListParams.dump_request(params) query = Dodopayments::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["entitlements/%1$s/grants", id], query: query, page: Dodopayments::Internal::DefaultPageNumberPagination, model: Dodopayments::Entitlements::EntitlementGrant, options: ) end |
#revoke(grant_id, id:, request_options: {}) ⇒ Dodopayments::Models::Entitlements::EntitlementGrant
Revoke a single grant. Idempotent: re-revoking an already-revoked grant returns the grant in its current state.
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/dodopayments/resources/entitlements/grants.rb', line 88 def revoke(grant_id, params) parsed, = Dodopayments::Entitlements::GrantRevokeParams.dump_request(params) id = parsed.delete(:id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["entitlements/%1$s/grants/%2$s", id, grant_id], model: Dodopayments::Entitlements::EntitlementGrant, options: ) end |