Class: Privy::Resources::Intents

Inherits:
Object
  • Object
show all
Defined in:
lib/privy/resources/intents.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Intents

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 Intents.

Parameters:



376
377
378
# File 'lib/privy/resources/intents.rb', line 376

def initialize(client:)
  @client = client
end

Instance Method Details

#create_policy_rule(policy_id, action:, conditions:, method_:, name:, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::RuleIntentResponse

Some parameter documentations has been truncated, see Models::IntentCreatePolicyRuleParams for more details.

Create an intent to add a rule to a policy. The intent must be authorized by the policy owner before it can be executed.



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/privy/resources/intents.rb', line 72

def create_policy_rule(policy_id, params)
  parsed, options = Privy::IntentCreatePolicyRuleParams.dump_request(params)
  header_params = {privy_request_expiry: "privy-request-expiry"}
  @client.request(
    method: :post,
    path: ["v1/intents/policies/%1$s/rules", policy_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::RuleIntentResponse,
    options: options
  )
end

#delete_policy_rule(rule_id, policy_id:, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::RuleIntentResponse

Some parameter documentations has been truncated, see Models::IntentDeletePolicyRuleParams for more details.

Create an intent to delete a rule from a policy. The intent must be authorized by the policy owner before it can be executed.

Parameters:

  • rule_id (String)

    Path param: ID of the rule.

  • policy_id (String)

    Path param: ID of the policy.

  • privy_request_expiry (String)

    Header param: Request expiry. Value is a Unix timestamp in milliseconds represen

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/privy/resources/intents.rb', line 104

def delete_policy_rule(rule_id, params)
  parsed, options = Privy::IntentDeletePolicyRuleParams.dump_request(params)
  policy_id =
    parsed.delete(:policy_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v1/intents/policies/%1$s/rules/%2$s", policy_id, rule_id],
    headers: parsed.transform_keys(privy_request_expiry: "privy-request-expiry"),
    model: Privy::RuleIntentResponse,
    options: options
  )
end

#get(intent_id, request_options: {}) ⇒ Privy::Models::RpcIntentResponse, ...

Retrieve an intent by ID. Returns the intent details including its current status, authorization details, and execution result if applicable.



131
132
133
134
135
136
137
138
# File 'lib/privy/resources/intents.rb', line 131

def get(intent_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/intents/%1$s", intent_id],
    model: Privy::IntentResponse,
    options: params[:request_options]
  )
end

#list(created_by_id: nil, current_user_has_signed: nil, cursor: nil, intent_type: nil, limit: nil, pending_member_id: nil, resource_id: nil, sort_by: nil, status: nil, request_options: {}) ⇒ Privy::Internal::Cursor<Privy::Models::RpcIntentResponse, Privy::Models::TransferIntentResponse, Privy::Models::WalletIntentResponse, Privy::Models::PolicyIntentResponse, Privy::Models::RuleIntentResponse, Privy::Models::KeyQuorumIntentResponse>

List intents for an app. Returns a paginated list of intents with their current status and details.

Parameters:

Returns:

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/privy/resources/intents.rb', line 34

def list(params = {})
  parsed, options = Privy::IntentListParams.dump_request(params)
  query = Privy::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/intents",
    query: query,
    page: Privy::Internal::Cursor,
    model: Privy::IntentResponse,
    options: options
  )
end

#rpc(wallet_id, wallet_rpc_request_body:, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::RpcIntentResponse

Some parameter documentations has been truncated, see Models::IntentRpcParams for more details.

Create an intent to execute an RPC method on a wallet. The intent must be authorized by either the wallet owner or signers before it can be executed.



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/privy/resources/intents.rb', line 159

def rpc(wallet_id, params)
  parsed, options = Privy::IntentRpcParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/intents/wallets/%1$s/rpc", wallet_id],
    headers: parsed.except(:wallet_rpc_request_body).transform_keys(privy_request_expiry: "privy-request-expiry"),
    body: parsed[:wallet_rpc_request_body],
    model: Privy::RpcIntentResponse,
    options: options
  )
end

#transfer(wallet_id, destination:, source:, amount_type: nil, fee_configuration: nil, slippage_bps: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::TransferIntentResponse

Some parameter documentations has been truncated, see Models::IntentTransferParams for more details.

Create an intent to execute a token transfer via a wallet. The intent must be authorized by either the wallet owner or signers before it can be executed.

Parameters:

Returns:

See Also:



198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/privy/resources/intents.rb', line 198

def transfer(wallet_id, params)
  parsed, options = Privy::IntentTransferParams.dump_request(params)
  header_params = {privy_request_expiry: "privy-request-expiry"}
  @client.request(
    method: :post,
    path: ["v1/intents/wallets/%1$s/transfer", wallet_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::TransferIntentResponse,
    options: options
  )
end

#update_key_quorum(key_quorum_id, authorization_threshold: nil, display_name: nil, key_quorum_ids: nil, public_keys: nil, user_ids: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::KeyQuorumIntentResponse

Some parameter documentations has been truncated, see Models::IntentUpdateKeyQuorumParams for more details.

Create an intent to update a key quorum. The intent must be authorized by the key quorum members before it can be executed.

Parameters:

  • key_quorum_id (String)

    Path param: ID of the key quorum.

  • authorization_threshold (Float)

    Body param: The number of keys that must sign for an action to be valid. Must be

  • display_name (String)

    Body param

  • key_quorum_ids (Array<String>)

    Body param: List of key quorum IDs that should be members of this key quorum. Ke

  • public_keys (Array<String>)

    Body param: List of P-256 public keys of the keys that should be authorized to s

  • user_ids (Array<String>)

    Body param: List of user IDs of the users that should be authorized to sign on t

  • privy_request_expiry (String)

    Header param: Request expiry. Value is a Unix timestamp in milliseconds represen

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/privy/resources/intents.rb', line 238

def update_key_quorum(key_quorum_id, params = {})
  parsed, options = Privy::IntentUpdateKeyQuorumParams.dump_request(params)
  header_params = {privy_request_expiry: "privy-request-expiry"}
  @client.request(
    method: :patch,
    path: ["v1/intents/key_quorums/%1$s", key_quorum_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::KeyQuorumIntentResponse,
    options: options
  )
end

#update_policy(policy_id, name: nil, owner: nil, owner_id: nil, rules: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::PolicyIntentResponse

Some parameter documentations has been truncated, see Models::IntentUpdatePolicyParams for more details.

Create an intent to update a policy. The intent must be authorized by the policy owner before it can be executed.

Parameters:

  • policy_id (String)

    Path param: ID of the policy.

  • name (String)

    Body param: Name to assign to policy.

  • owner (Privy::Models::OwnerInputUser, Privy::Models::OwnerInputPublicKey, nil)

    Body param: The owner of the resource, specified as a Privy user ID, a P-256 pub

  • owner_id (String, nil)

    Body param: The key quorum ID to set as the owner of the resource. If you provid

  • rules (Array<Privy::Models::PolicyRuleRequestBody>)

    Body param

  • privy_request_expiry (String)

    Header param: Request expiry. Value is a Unix timestamp in milliseconds represen

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/privy/resources/intents.rb', line 276

def update_policy(policy_id, params = {})
  parsed, options = Privy::IntentUpdatePolicyParams.dump_request(params)
  header_params = {privy_request_expiry: "privy-request-expiry"}
  @client.request(
    method: :patch,
    path: ["v1/intents/policies/%1$s", policy_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::PolicyIntentResponse,
    options: options
  )
end

#update_policy_rule(rule_id, policy_id:, action:, conditions:, method_:, name:, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::RuleIntentResponse

Some parameter documentations has been truncated, see Models::IntentUpdatePolicyRuleParams for more details.

Create an intent to update a rule on a policy. The intent must be authorized by the policy owner before it can be executed.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/privy/resources/intents.rb', line 316

def update_policy_rule(rule_id, params)
  parsed, options = Privy::IntentUpdatePolicyRuleParams.dump_request(params)
  policy_id =
    parsed.delete(:policy_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  header_params = {privy_request_expiry: "privy-request-expiry"}
  @client.request(
    method: :patch,
    path: ["v1/intents/policies/%1$s/rules/%2$s", policy_id, rule_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::RuleIntentResponse,
    options: options
  )
end

#update_wallet(wallet_id, additional_signers: nil, display_name: nil, owner: nil, owner_id: nil, policy_ids: nil, privy_request_expiry: nil, request_options: {}) ⇒ Privy::Models::WalletIntentResponse

Some parameter documentations has been truncated, see Models::IntentUpdateWalletParams for more details.

Create an intent to update a wallet. The intent must be authorized by the wallet owner before it can be executed.

Parameters:

  • wallet_id (String)

    Path param: ID of the wallet.

  • additional_signers (Array<Privy::Models::AdditionalSignerItemInput>)

    Body param: Additional signers for the wallet.

  • display_name (String, nil)

    Body param: A human-readable label for the wallet. Set to null to clear.

  • owner (Privy::Models::OwnerInputUser, Privy::Models::OwnerInputPublicKey, nil)

    Body param: The owner of the resource, specified as a Privy user ID, a P-256 pub

  • owner_id (String, nil)

    Body param: The key quorum ID to set as the owner of the resource. If you provid

  • policy_ids (Array<String>)

    Body param: New policy IDs to enforce on the wallet. Currently, only one policy

  • privy_request_expiry (String)

    Header param: Request expiry. Value is a Unix timestamp in milliseconds represen

  • request_options (Privy::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/privy/resources/intents.rb', line 360

def update_wallet(wallet_id, params = {})
  parsed, options = Privy::IntentUpdateWalletParams.dump_request(params)
  header_params = {privy_request_expiry: "privy-request-expiry"}
  @client.request(
    method: :patch,
    path: ["v1/intents/wallets/%1$s", wallet_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Privy::WalletIntentResponse,
    options: options
  )
end