Class: Pago::V2026_04::Services::Metrics
- Defined in:
- lib/pago/v2026_04/services/metrics.rb,
sig/pago/v2026_04/generated.rbs
Instance Attribute Summary
Attributes inherited from Service
Instance Method Summary collapse
-
#create_dashboard(body: {}) ⇒ Models::MetricDashboardSchema
Create a user-defined metric dashboard.
-
#delete_dashboard(id) ⇒ nil
Delete a user-defined metric dashboard.
-
#export(start_date:, end_date:, timezone: "UTC", interval:, organization_id: nil, product_id: nil, billing_type: nil, customer_id: nil, metrics: nil) ⇒ String
Export metrics as a CSV file.
-
#get(start_date:, end_date:, timezone: "UTC", interval:, organization_id: nil, product_id: nil, billing_type: nil, customer_id: nil, metrics: nil) ⇒ Models::MetricsResponse
Get metrics about your orders and subscriptions.
-
#get_dashboard(id) ⇒ Models::MetricDashboardSchema
Get a user-defined metric dashboard by ID.
-
#limits ⇒ Models::MetricsLimits
Get the interval limits for the metrics endpoint.
-
#list_dashboards(organization_id: nil) ⇒ Array<Models::MetricDashboardSchema>
List user-defined metric dashboards.
-
#update_dashboard(id, body: {}) ⇒ Models::MetricDashboardSchema
Update a user-defined metric dashboard.
Methods inherited from Service
Constructor Details
This class inherits a constructor from Pago::Service
Instance Method Details
#create_dashboard(body: {}) ⇒ Models::MetricDashboardSchema
Create a user-defined metric dashboard.
Scopes: metrics:write
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/pago/v2026_04/services/metrics.rb', line 110 def create_dashboard(body: {}) data = client.request( http_method: "POST", path: "/v1/metrics/dashboards", path_params: {}, query: {}, body: body, response_type: :json, errors: { 422 => Errors::HTTPValidationError } ) Models::MetricDashboardSchema.from_json(data) end |
#delete_dashboard(id) ⇒ nil
Delete a user-defined metric dashboard.
Scopes: metrics:write
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/pago/v2026_04/services/metrics.rb', line 151 def delete_dashboard(id) client.request( http_method: "DELETE", path: "/v1/metrics/dashboards/{id}", path_params: { "id" => id }, query: {}, response_type: :none, errors: { 422 => Errors::HTTPValidationError } ) end |
#export(start_date:, end_date:, timezone: "UTC", interval:, organization_id: nil, product_id: nil, billing_type: nil, customer_id: nil, metrics: nil) ⇒ String
Export metrics as a CSV file.
Scopes: metrics:read
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pago/v2026_04/services/metrics.rb', line 53 def export(start_date:, end_date:, timezone: "UTC", interval:, organization_id: nil, product_id: nil, billing_type: nil, customer_id: nil, metrics: nil) client.request( http_method: "GET", path: "/v1/metrics/export", path_params: {}, query: { "start_date" => start_date, "end_date" => end_date, "timezone" => timezone, "interval" => interval, "organization_id" => organization_id, "product_id" => product_id, "billing_type" => billing_type, "customer_id" => customer_id, "metrics" => metrics }, response_type: :text, errors: { 422 => Errors::HTTPValidationError } ) end |
#get(start_date:, end_date:, timezone: "UTC", interval:, organization_id: nil, product_id: nil, billing_type: nil, customer_id: nil, metrics: nil) ⇒ Models::MetricsResponse
Get metrics about your orders and subscriptions.
Currency values are output in cents.
Scopes: metrics:read
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pago/v2026_04/services/metrics.rb', line 25 def get(start_date:, end_date:, timezone: "UTC", interval:, organization_id: nil, product_id: nil, billing_type: nil, customer_id: nil, metrics: nil) data = client.request( http_method: "GET", path: "/v1/metrics/", path_params: {}, query: { "start_date" => start_date, "end_date" => end_date, "timezone" => timezone, "interval" => interval, "organization_id" => organization_id, "product_id" => product_id, "billing_type" => billing_type, "customer_id" => customer_id, "metrics" => metrics }, response_type: :json, errors: { 422 => Errors::HTTPValidationError } ) Models::MetricsResponse.from_json(data) end |
#get_dashboard(id) ⇒ Models::MetricDashboardSchema
Get a user-defined metric dashboard by ID.
Scopes: metrics:read
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/pago/v2026_04/services/metrics.rb', line 131 def get_dashboard(id) data = client.request( http_method: "GET", path: "/v1/metrics/dashboards/{id}", path_params: { "id" => id }, query: {}, response_type: :json, errors: { 422 => Errors::HTTPValidationError } ) Models::MetricDashboardSchema.from_json(data) end |
#limits ⇒ Models::MetricsLimits
Get the interval limits for the metrics endpoint.
Scopes: metrics:read
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/pago/v2026_04/services/metrics.rb', line 70 def limits() data = client.request( http_method: "GET", path: "/v1/metrics/limits", path_params: {}, query: {}, response_type: :json, errors: { } ) Models::MetricsLimits.from_json(data) end |
#list_dashboards(organization_id: nil) ⇒ Array<Models::MetricDashboardSchema>
List user-defined metric dashboards.
Scopes: metrics:read
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/pago/v2026_04/services/metrics.rb', line 90 def list_dashboards(organization_id: nil) data = client.request( http_method: "GET", path: "/v1/metrics/dashboards", path_params: {}, query: { "organization_id" => organization_id }, response_type: :json, errors: { 422 => Errors::HTTPValidationError } ) ::Pago::Serde.array(data) { |item0| Models::MetricDashboardSchema.from_json(item0) } end |
#update_dashboard(id, body: {}) ⇒ Models::MetricDashboardSchema
Update a user-defined metric dashboard.
Scopes: metrics:write
171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/pago/v2026_04/services/metrics.rb', line 171 def update_dashboard(id, body: {}) data = client.request( http_method: "PATCH", path: "/v1/metrics/dashboards/{id}", path_params: { "id" => id }, query: {}, body: body, response_type: :json, errors: { 422 => Errors::HTTPValidationError } ) Models::MetricDashboardSchema.from_json(data) end |