Class: Versacommerce::ThemeAPIClient::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/versacommerce/theme_api_client/fetcher.rb

Constant Summary collapse

RecordNotFoundError =
Class.new(StandardError)
UnauthorizedError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Fetcher

Returns a new instance of Fetcher.



15
16
17
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 15

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



13
14
15
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 13

def client
  @client
end

Instance Method Details

#delete(path = {}) ⇒ Object



55
56
57
58
59
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 55

def delete(path = {})
  url = url_for_path(path)
  response = with_headers.delete(url)
  handle_response(response, url)
end

#get(path) ⇒ Object



19
20
21
22
23
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 19

def get(path)
  url = url_for_path(path)
  response = with_headers.get(url)
  handle_response(response, url)
end

#head(path) ⇒ Object



25
26
27
28
29
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 25

def head(path)
  url = url_for_path(path)
  response = with_headers.head(url)
  handle_response(response, url)
end

#patch(path, json = {}) ⇒ Object



43
44
45
46
47
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 43

def patch(path, json = {})
  url = url_for_path(path)
  response = with_headers.patch(url_for_path(path), json: json)
  handle_response(response, url)
end

#patch_form(path, form_data = {}) ⇒ Object



49
50
51
52
53
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 49

def patch_form(path, form_data = {})
  url = url_for_path(path)
  response = with_headers.patch(url_for_path(path), form: form_data)
  handle_response(response, url)
end

#post(path, json = {}) ⇒ Object



31
32
33
34
35
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 31

def post(path, json = {})
  url = url_for_path(path)
  response = with_headers.post(url_for_path(path), json: json)
  handle_response(response, url)
end

#post_form(path, form_data = {}) ⇒ Object



37
38
39
40
41
# File 'lib/versacommerce/theme_api_client/fetcher.rb', line 37

def post_form(path, form_data = {})
  url = url_for_path(path)
  response = with_headers.post(url_for_path(path), form: form_data)
  handle_response(response, url)
end