Class: WCC::Contentful::SimpleClient

Inherits:
Object
  • Object
show all
Defined in:
lib/wcc/contentful/simple_client.rb,
lib/wcc/contentful/simple_client/response.rb

Direct Known Subclasses

Cdn, Management

Defined Under Namespace

Classes: ApiError, Cdn, Management, NotFoundError, Response, SyncResponse

Instance Method Summary collapse

Constructor Details

#initialize(api_url:, space:, access_token:, **options) ⇒ SimpleClient

Returns a new instance of SimpleClient.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wcc/contentful/simple_client.rb', line 9

def initialize(api_url:, space:, access_token:, **options)
  @api_url = URI.join(api_url, '/spaces/', space + '/')
  @space = space
  @access_token = access_token

  @get_http = options[:override_get_http] if options[:override_get_http].present?

  @options = options
  @query_defaults = {}
  @query_defaults[:locale] = @options[:default_locale] if @options[:default_locale]
end

Instance Method Details

#get(path, query = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/wcc/contentful/simple_client.rb', line 21

def get(path, query = {})
  url = URI.join(@api_url, path)

  Response.new(self,
    { url: url, query: query },
    get_http(url, query))
end