class FrederickAPI::V2::Resource

Class from which Frederick V2 Resources inherit Inherits functionality from JsonApiClient::Resource

Attributes

custom_headers[RW]

Public Class Methods

_header_store() click to toggle source
# File lib/frederick_api/v2/resource.rb, line 57
def self._header_store
  Thread.current['frederick_api_header_store'] ||= {}
end
all_records() click to toggle source
# File lib/frederick_api/v2/resource.rb, line 26
def self.all_records
  self.all.pages.all_records
end
custom_headers() click to toggle source
Calls superclass method
# File lib/frederick_api/v2/resource.rb, line 53
def self.custom_headers
  super.merge(x_api_key: top_level_namespace.config.api_key)
end
new(params = {}) click to toggle source
Calls superclass method
# File lib/frederick_api/v2/resource.rb, line 17
def initialize(params = {})
  self.custom_headers = self.class.custom_headers
  super
end
site() click to toggle source
# File lib/frederick_api/v2/resource.rb, line 34
def self.site
  "#{top_level_namespace.config.base_url}/v2/"
end
top_level_namespace() click to toggle source
# File lib/frederick_api/v2/resource.rb, line 30
def self.top_level_namespace
  @top_level_namespace ||= self.to_s.split('::').first.constantize
end
with_access_token(token) { || ... } click to toggle source
# File lib/frederick_api/v2/resource.rb, line 38
def self.with_access_token(token)
  with_access_token_and_headers(token) do
    yield
  end
end
with_access_token_and_headers(token, headers = {}) { || ... } click to toggle source
# File lib/frederick_api/v2/resource.rb, line 44
def self.with_access_token_and_headers(token, headers = {})
  with_headers(
    authorization: "Bearer #{token}",
    **headers
  ) do
    yield
  end
end

Public Instance Methods

has_errors?() click to toggle source
# File lib/frederick_api/v2/resource.rb, line 22
def has_errors?
  self.errors.present?
end