Class: Whop_sdk::CompanyTokenTransactions::Client
- Inherits:
-
Object
- Object
- Whop_sdk::CompanyTokenTransactions::Client
- Defined in:
- lib/whop_sdk/company_token_transactions/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::CompanyTokenTransaction
Create a token transaction to add, subtract, or transfer tokens for a member within a company.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::CompanyTokenTransactions::Types::ListCompanyTokenTransactionsResponse
Returns a paginated list of token transactions for a user or company, depending on the authenticated actor, with optional filtering by user and transaction type.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::CompanyTokenTransaction
Retrieves the details of an existing company token transaction.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/company_token_transactions/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::CompanyTokenTransaction
Create a token transaction to add, subtract, or transfer tokens for a member within a company.
Required permissions:
company_token_transaction:createmember:basic:readcompany:basic:read
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/whop_sdk/company_token_transactions/client.rb', line 104 def create(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "company_token_transactions", body: Whop_sdk::CompanyTokenTransactions::Types::CreateCompanyTokenTransactionsRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::CompanyTokenTransaction.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list(request_options: {}, **params) ⇒ Whop_sdk::CompanyTokenTransactions::Types::ListCompanyTokenTransactionsResponse
Returns a paginated list of token transactions for a user or company, depending on the authenticated actor, with optional filtering by user and transaction type.
Required permissions:
company_token_transaction:readmember:basic:readcompany:basic:read
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/whop_sdk/company_token_transactions/client.rb', line 45 def list(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["after"] = params[:after] if params.key?(:after) query_params["before"] = params[:before] if params.key?(:before) query_params["first"] = params[:first] if params.key?(:first) query_params["last"] = params[:last] if params.key?(:last) query_params["company_id"] = params[:company_id] if params.key?(:company_id) query_params["user_id"] = params[:user_id] if params.key?(:user_id) query_params["transaction_type"] = params[:transaction_type] if params.key?(:transaction_type) Whop_sdk::Internal::CursorItemIterator.new( cursor_field: :end_cursor, item_field: :data, initial_cursor: query_params["after"] ) do |next_cursor| query_params["after"] = next_cursor request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "company_token_transactions", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) parsed_response = Whop_sdk::CompanyTokenTransactions::Types::ListCompanyTokenTransactionsResponse.load(response.body) [parsed_response, response] else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::CompanyTokenTransaction
Retrieves the details of an existing company token transaction.
Required permissions:
company_token_transaction:readmember:basic:readcompany:basic:read
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/whop_sdk/company_token_transactions/client.rb', line 147 def retrieve(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "company_token_transactions/#{URI.encode_uri_component(params[:id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Types::CompanyTokenTransaction.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |