Class: Whop_sdk::Exports::Client
- Inherits:
-
Object
- Object
- Whop_sdk::Exports::Client
- Defined in:
- lib/whop_sdk/exports/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::Export
Starts an asynchronous CSV export of a resource for an account.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Whop_sdk::Exports::Types::ListExportsResponse
Lists the exports requested for an account, newest first.
-
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::Export
Fetches an export's status and, once complete, its download link.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/whop_sdk/exports/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Whop_sdk::Types::Export
Starts an asynchronous CSV export of a resource for an account. Returns the export in pending; poll GET /exports/{id} until download_url is set.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/whop_sdk/exports/client.rb', line 82 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: "exports", body: Whop_sdk::Exports::Types::CreateExportsRequest.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::Export.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::Exports::Types::ListExportsResponse
Lists the exports requested for an account, newest first. Only exports of resources the credential is allowed to export are returned.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/whop_sdk/exports/client.rb', line 35 def list(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["account_id"] = params[:account_id] if params.key?(:account_id) query_params["resource"] = params[:resource] if params.key?(:resource) query_params["status"] = params[:status] if params.key?(:status) query_params["created_after"] = params[:created_after] if params.key?(:created_after) query_params["created_before"] = params[:created_before] if params.key?(:created_before) query_params["order"] = params[:order] if params.key?(:order) query_params["direction"] = params[:direction] if params.key?(:direction) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "exports", 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) Whop_sdk::Exports::Types::ListExportsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::Export
Fetches an export's status and, once complete, its download link.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/whop_sdk/exports/client.rb', line 120 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: "exports/#{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::Export.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |