Class: Assinafy::Resources::UserResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- Assinafy::Resources::UserResource
- Defined in:
- lib/assinafy/resources/user_resource.rb,
sig/assinafy.rbs
Overview
The authenticated user's own profile and cross-account KPIs.
See https://api.assinafy.com.br/v1/docs for the User Object.
Constant Summary collapse
- NOTIFICATION_PREFERENCE_CODES =
%w[ DocumentCompleted SignerDeclined DocumentCancelled DocumentAboutToExpire DocumentExpired DocumentExpirationReset DocumentProcessingFailed TemplateProcessingFailed SignerWhatsappFailed ].freeze
Constants inherited from BaseResource
BaseResource::AUTH_HEADERS, BaseResource::PAGINATION_HEADERS, BaseResource::PATH_SEGMENT
Instance Method Summary collapse
-
#me ⇒ Hash{String=>Object}
Fetch the authenticated user's profile.
-
#notification_preferences ⇒ Hash{String=>Boolean}
Fetch all owner-facing document email preferences.
-
#stats(granularity: nil, month: nil) ⇒ Array<Hash>
Fetch the authenticated user's cross-account document KPIs.
-
#update_notification_preferences(preferences) ⇒ Hash{String=>Boolean}
Merge selected owner-facing document email preferences.
Methods inherited from BaseResource
Constructor Details
This class inherits a constructor from Assinafy::Resources::BaseResource
Instance Method Details
#me ⇒ Hash{String=>Object}
Fetch the authenticated user's profile. The current OpenAPI response is
an AuthUser directly, while some sandbox deployments return the login-like
{ 'user' => AuthUser, 'accounts' => [...] } shape. The SDK does not reshape
either form; it returns the envelope's data value unchanged.
71 72 73 74 75 |
# File 'lib/assinafy/resources/user_resource.rb', line 71 def me call('Failed to fetch current user') do http_get('users/self') end end |
#notification_preferences ⇒ Hash{String=>Boolean}
Fetch all owner-facing document email preferences. All nine keys are returned and default to true. Account and security email is not configurable through this endpoint.
135 136 137 138 139 |
# File 'lib/assinafy/resources/user_resource.rb', line 135 def notification_preferences call('Failed to fetch notification preferences') do http_get('users/self/notification-preferences') end end |
#stats(granularity: nil, month: nil) ⇒ Array<Hash>
Documented in the API reference but not enabled on every environment — the sandbox currently returns 404 for this route.
Fetch the authenticated user's cross-account document KPIs.
108 109 110 111 112 |
# File 'lib/assinafy/resources/user_resource.rb', line 108 def stats(granularity: nil, month: nil) call_array('Failed to fetch user stats') do http_get('users/self/stats', query_params(granularity: granularity, month: month)) end end |
#update_notification_preferences(preferences) ⇒ Hash{String=>Boolean}
Merge selected owner-facing document email preferences.
Omitted keys keep their current values. The API returns the full nine-key map shown by #notification_preferences.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/assinafy/resources/user_resource.rb', line 167 def update_notification_preferences(preferences) preferences = require_payload(preferences, 'Notification preferences') raise ValidationError.new('At least one notification preference is required') if preferences.empty? preferences.each do |code, enabled| code = code.to_s unless NOTIFICATION_PREFERENCE_CODES.include?(code) raise ValidationError.new("Unknown notification preference: #{code}") end unless [true, false].include?(enabled) raise ValidationError.new("Notification preference #{code} must be boolean") end end call('Failed to update notification preferences') do http_put('users/self/notification-preferences', body_params(preferences)) end end |