Module: Shark

Extended by:
SingleForwardable
Defined in:
lib/shark.rb,
lib/shark/base.rb,
lib/shark/asset.rb,
lib/shark/error.rb,
lib/shark/group.rb,
lib/shark/rails.rb,
lib/shark/survey.rb,
lib/shark/account.rb,
lib/shark/consent.rb,
lib/shark/contact.rb,
lib/shark/package.rb,
lib/shark/version.rb,
lib/shark/activity.rb,
lib/shark/contract.rb,
lib/shark/membership.rb,
lib/shark/permission.rb,
lib/shark/contact_log.rb,
lib/shark/form_service.rb,
lib/shark/notification.rb,
lib/shark/configuration.rb,
lib/shark/rspec/helpers.rb,
lib/shark/mailing_service.rb,
lib/shark/client/connection.rb,
lib/shark/form_service/base.rb,
lib/shark/middleware/status.rb,
lib/shark/concerns/connected.rb,
lib/shark/survey_participant.rb,
lib/shark/form_service/v2/base.rb,
lib/shark/form_service/v2/form.rb,
lib/shark/mailing_service/base.rb,
lib/shark/mailing_service/mail.rb,
lib/shark/double_opt_in/request.rb,
lib/shark/mailing_service/mailer.rb,
lib/shark/rspec/helpers/fixtures.rb,
lib/shark/rspec/helpers/response.rb,
lib/shark/double_opt_in/execution.rb,
lib/shark/rspec/fake_asset_service.rb,
lib/shark/rspec/fake_double_opt_in.rb,
lib/shark/concerns/normalized_email.rb,
lib/shark/form_service/form/element.rb,
lib/shark/rspec/fake_survey_service.rb,
lib/shark/form_service/v2/form_input.rb,
lib/shark/middleware/compose_request.rb,
lib/shark/rspec/fake_contact_service.rb,
lib/shark/rspec/fake_mailing_service.rb,
lib/shark/rspec/helpers/cache_helper.rb,
lib/shark/form_service/form/container.rb,
lib/shark/form_service/form/structure.rb,
lib/shark/form_service/form/text_area.rb,
lib/shark/form_service/form/text_field.rb,
lib/shark/form_service/v2/form_version.rb,
lib/shark/form_service/form/rating_star.rb,
lib/shark/mailing_service/configuration.rb,
lib/shark/form_service/form/rating_scale.rb,
lib/shark/rspec/fake_notification_service.rb,
lib/shark/rspec/fake_asset_service/request.rb,
lib/shark/rspec/fake_double_opt_in/request.rb,
lib/shark/form_service/form/multiple_choice.rb,
lib/shark/mailing_service/renderers/context.rb,
lib/shark/rspec/fake_survey_service/request.rb,
lib/shark/rspec/helpers/form_service_helper.rb,
lib/shark/rspec/fake_asset_service/public_id.rb,
lib/shark/rspec/fake_contact_service/request.rb,
lib/shark/rspec/fake_mailing_service/request.rb,
lib/shark/rspec/fake_asset_service/object_cache.rb,
lib/shark/rspec/fake_double_opt_in/object_cache.rb,
lib/shark/mailing_service/renderers/erb_renderer.rb,
lib/shark/rspec/fake_survey_service/object_cache.rb,
lib/shark/rspec/fake_contact_service/object_cache.rb,
lib/shark/rspec/fake_notification_service/request.rb

Defined Under Namespace

Modules: AssetService, Client, Connected, ContactService, DoubleOptIn, FormService, MailingService, Middleware, NormalizedEmail, NotificationService, RSpec, SurveyService Classes: AccessDenied, Account, ActionNotSupportedError, Activity, ApiError, Asset, Base, ClientError, Configuration, ConnectionError, Consent, Contact, ContactLog, Contract, Error, Group, Membership, NotAuthorized, Notification, Package, Permission, Railtie, ResourceConflict, ResourceNotFound, ServerError, Survey, SurveyParticipant, UnexpectedStatus, UnprocessableEntity

Constant Summary collapse

VERSION =
'3.0.0'

Class Method Summary collapse

Class Method Details

.configure {|self.configuration| ... } ⇒ Object

Yields:

  • (self.configuration)


25
26
27
28
# File 'lib/shark.rb', line 25

def self.configure
  self.configuration ||= Configuration.new
  yield self.configuration
end

.service_tokenObject



50
51
52
# File 'lib/shark.rb', line 50

def self.service_token
  Thread.current['shark-service-token']
end

.service_token=(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



55
56
57
# File 'lib/shark.rb', line 55

def self.service_token=(value)
  Thread.current['shark-service-token'] = value
end

.with_service_token(token) ⇒ Object

Within the given block, add the service token authorization header to all api requests.

Parameters:

  • token (String)

    The service token for the authorization header

  • block (Block)

    The block where service token authorization will be set for



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/shark.rb', line 35

def self.with_service_token(token)
  if token.is_a?(String)
    self.service_token = token
  elsif token.respond_to?(:jwt)
    self.service_token = token.jwt
  else
    raise ArgumentError, 'Parameter :token must be kind of String.'
  end

  yield
ensure
  self.service_token = nil
end