Class: ERPC::UsageClient
- Inherits:
-
Object
- Object
- ERPC::UsageClient
- Defined in:
- lib/erpc_sdk/rest.rb
Instance Method Summary collapse
- #get_monthly_api_key_usage(year_month = nil) ⇒ Object
-
#initialize(transport) ⇒ UsageClient
constructor
A new instance of UsageClient.
Constructor Details
#initialize(transport) ⇒ UsageClient
Returns a new instance of UsageClient.
63 64 65 |
# File 'lib/erpc_sdk/rest.rb', line 63 def initialize(transport) @transport = transport end |
Instance Method Details
#get_monthly_api_key_usage(year_month = nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/erpc_sdk/rest.rb', line 67 def get_monthly_api_key_usage(year_month = nil) if !year_month.nil? && !YEAR_MONTH.match?(year_month) raise ConfigError, "year_month must use YYYY-MM format" end envelope = Validation.mapping(@transport.get("/v3/user/api-keys/usage", "yearMonth" => year_month)) raise InvalidResponseError unless envelope["success"] == true usage = Validation.mapping(envelope["message"]) validate_usage(usage) usage rescue InvalidResponseError raise InvalidResponseError, "ERPC returned an invalid monthly API key usage response" end |