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::Statistic::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::Statistic::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::Statistic::Types::StatBasicQueryRecord]
Retrieves the subscription statistics for a given interval for a paypoint or organization.
-
#vendor_basic_stats(request_options: {}, **params) ⇒ Array[Payabli::Statistic::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::Statistic::Types::StatBasicExtendedQueryRecord]
Retrieves the basic statistics for an organization or a paypoint, for a given time period, grouped by a particular frequency.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/payabli/statistic/client.rb', line 32 def basic_stats(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[end_date parameters start_date] 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) params = params.except(*query_param_names) 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)}", 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::Statistic::Types::SubscriptionStatsQueryRecord]
Retrieves the basic statistics for a customer for a specific time period, grouped by a selected frequency.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/payabli/statistic/client.rb', line 75 def customer_basic_stats(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[parameters] query_params = {} query_params["parameters"] = params[:parameters] if params.key?(:parameters) params = params.except(*query_param_names) 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)}", 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::Statistic::Types::StatBasicQueryRecord]
Retrieves the subscription statistics for a given interval for a paypoint or organization.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/payabli/statistic/client.rb', line 116 def sub_stats(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[parameters] query_params = {} query_params["parameters"] = params[:parameters] if params.key?(:parameters) params = params.except(*query_param_names) 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)}", 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::Statistic::Types::StatisticsVendorQueryRecord]
Retrieve the basic statistics about a vendor for a given time period, grouped by frequency.
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/payabli/statistic/client.rb', line 157 def vendor_basic_stats(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[parameters] query_params = {} query_params["parameters"] = params[:parameters] if params.key?(:parameters) params = params.except(*query_param_names) 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)}", 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 |