Module: Mobiscroll::Connect
- Defined in:
- lib/mobiscroll/connect.rb,
lib/mobiscroll/connect/client.rb,
lib/mobiscroll/connect/config.rb,
lib/mobiscroll/connect/errors.rb,
lib/mobiscroll/connect/models.rb,
lib/mobiscroll/connect/version.rb,
lib/mobiscroll/connect/provider.rb,
lib/mobiscroll/connect/api_client.rb,
lib/mobiscroll/connect/resources/auth.rb,
lib/mobiscroll/connect/resources/events.rb,
lib/mobiscroll/connect/resources/calendars.rb
Defined Under Namespace
Modules: Provider, Resources Classes: ApiClient, Attendee, AuthenticationError, Calendar, CalendarEvent, Client, Config, ConnectedAccount, ConnectionStatus, DisconnectResponse, Error, EventsListResponse, NetworkError, NotFoundError, RateLimitError, RecurrenceRule, ServerError, TokenResponse, ValidationError
Constant Summary collapse
- DEFAULT_BASE_URL =
'https://connect.mobiscroll.com/api'- DEFAULT_TIMEOUT =
30- VERSION =
'1.0.2'
Class Method Summary collapse
-
.map_response_error(status, body, headers) ⇒ Object
Maps an HTTP response (status + body hash + headers) to the matching typed error.
Class Method Details
.map_response_error(status, body, headers) ⇒ Object
Maps an HTTP response (status + body hash + headers) to the matching typed error. Returns nil for 2xx responses.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/mobiscroll/connect/errors.rb', line 64 def self.map_response_error(status, body, headers) = body.is_a?(Hash) ? (body['message'] || body[:message]) : nil ||= "HTTP #{status}" case status when 401, 403 AuthenticationError.new() when 404 NotFoundError.new() when 400, 422 details = body.is_a?(Hash) ? (body['details'] || body[:details]) : nil ValidationError.new(, details: details) when 429 retry_after = headers && (headers['retry-after'] || headers['Retry-After']) retry_after_int = retry_after&.to_i RateLimitError.new(, retry_after: retry_after_int) when 500..599 ServerError.new(, status_code: status) end end |