Class: Payabli::Statistic::Client
- Inherits:
-
Object
- Object
- Payabli::Statistic::Client
- Defined in:
- lib/payabli/statistic/client.rb
Instance Method Summary collapse
-
#basic_stats(request_options: {}, **params) ⇒ Array[Payabli::Types::StatBasicExtendedQueryRecord]
Retrieves the basic statistics for an organization or a paypoint, for a given time period, grouped by a particular frequency.
-
#customer_basic_stats(request_options: {}, **params) ⇒ Array[Payabli::Types::SubscriptionStatsQueryRecord]
Retrieves the basic statistics for a customer for a specific time period, grouped by a selected frequency.
- #initialize(client:) ⇒ void constructor
-
#sub_stats(request_options: {}, **params) ⇒ Array[Payabli::Types::StatBasicQueryRecord]
Retrieves the subscription statistics for a given interval for a paypoint or organization.
-
#vendor_basic_stats(request_options: {}, **params) ⇒ Array[Payabli::Types::StatisticsVendorQueryRecord]
Retrieve the basic statistics about a vendor for a given time period, grouped by frequency.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/statistic/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#basic_stats(request_options: {}, **params) ⇒ Array[Payabli::Types::StatBasicExtendedQueryRecord]
Retrieves the basic statistics for an organization or a paypoint, for a given time period, grouped by a particular frequency.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/payabli/statistic/client.rb', line 42 def basic_stats(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["endDate"] = params[:end_date] if params.key?(:end_date) query_params["parameters"] = params[:parameters] if params.key?(:parameters) query_params["startDate"] = params[:start_date] if params.key?(:start_date) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Statistic/basic/#{URI.encode_uri_component(params[:mode].to_s)}/#{URI.encode_uri_component(params[:freq].to_s)}/#{URI.encode_uri_component(params[:level].to_s)}/#{URI.encode_uri_component(params[:entry_id].to_s)}", headers: headers, query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#customer_basic_stats(request_options: {}, **params) ⇒ Array[Payabli::Types::SubscriptionStatsQueryRecord]
Retrieves the basic statistics for a customer for a specific time period, grouped by a selected frequency.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/payabli/statistic/client.rb', line 92 def customer_basic_stats(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["parameters"] = params[:parameters] if params.key?(:parameters) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Statistic/customerbasic/#{URI.encode_uri_component(params[:mode].to_s)}/#{URI.encode_uri_component(params[:freq].to_s)}/#{URI.encode_uri_component(params[:customer_id].to_s)}", headers: headers, query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#sub_stats(request_options: {}, **params) ⇒ Array[Payabli::Types::StatBasicQueryRecord]
Retrieves the subscription statistics for a given interval for a paypoint or organization.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/payabli/statistic/client.rb', line 140 def sub_stats(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["parameters"] = params[:parameters] if params.key?(:parameters) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Statistic/subscriptions/#{URI.encode_uri_component(params[:interval].to_s)}/#{URI.encode_uri_component(params[:level].to_s)}/#{URI.encode_uri_component(params[:entry_id].to_s)}", headers: headers, query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#vendor_basic_stats(request_options: {}, **params) ⇒ Array[Payabli::Types::StatisticsVendorQueryRecord]
Retrieve the basic statistics about a vendor for a given time period, grouped by frequency.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/payabli/statistic/client.rb', line 188 def vendor_basic_stats(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["parameters"] = params[:parameters] if params.key?(:parameters) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Statistic/vendorbasic/#{URI.encode_uri_component(params[:mode].to_s)}/#{URI.encode_uri_component(params[:freq].to_s)}/#{URI.encode_uri_component(params[:id_vendor].to_s)}", headers: headers, query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |