Class: SecondAmendmentWholesale::Image

Inherits:
Base
  • Object
show all
Includes:
API
Defined in:
lib/second_amendment_wholesale/image.rb

Constant Summary

Constants included from API

API::ROOT_API_URL

Instance Method Summary collapse

Methods included from API

#delete_request, #get_request, #post_request, #put_request

Constructor Details

#initialize(options = {}) ⇒ Image

Returns a new instance of Image.



6
7
8
9
10
11
12
13
14
# File 'lib/second_amendment_wholesale/image.rb', line 6

def initialize(options = {})
  requires!(options, :token)
  @options = options

  @headers = [ 
    *auth_header(@options[:token]),
    *content_type_header('application/json'),
  ].to_h
end

Instance Method Details

#url(item_number) ⇒ Object



16
17
18
19
20
21
# File 'lib/second_amendment_wholesale/image.rb', line 16

def url(item_number)
  response = get_request("products/#{item_number}/media", @headers).body
  
  return response.first[:file] if response.present?
  nil
end