Class: Nuvemshop::Request

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/nuvemshop/request.rb

Direct Known Subclasses

Orders

Defined Under Namespace

Classes: Error

Constant Summary collapse

BASE_URL =
'https://api.tiendanube.com/v1'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*block) {|block| ... } ⇒ Request

Returns a new instance of Request.

Yields:

  • (block)


12
13
14
15
16
17
# File 'lib/nuvemshop/request.rb', line 12

def initialize(*block)
  @base_url = "#{BASE_URL}/#{set_store}"
  @headers = set_headers
  yield block if block_given?
  @options = { headers: @headers }
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



8
9
10
# File 'lib/nuvemshop/request.rb', line 8

def access_token
  @access_token
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/nuvemshop/request.rb', line 8

def options
  @options
end

#responseObject

Returns the value of attribute response.



7
8
9
# File 'lib/nuvemshop/request.rb', line 7

def response
  @response
end

#user_idObject (readonly)

Returns the value of attribute user_id.



8
9
10
# File 'lib/nuvemshop/request.rb', line 8

def user_id
  @user_id
end

Class Method Details

.respond_with(response, formatter) ⇒ Object



35
36
37
# File 'lib/nuvemshop/request.rb', line 35

def self.respond_with(response, formatter)
  Response.new(response, formatter)
end

Instance Method Details

#delete(opts = {}) ⇒ Object



31
32
33
# File 'lib/nuvemshop/request.rb', line 31

def delete(opts = {})
  perform_request(__method__, opts)
end

#get(opts = {}) ⇒ Object



19
20
21
# File 'lib/nuvemshop/request.rb', line 19

def get(opts = {})
  perform_request(__method__, opts)
end

#post(opts = {}) ⇒ Object



23
24
25
# File 'lib/nuvemshop/request.rb', line 23

def post(opts = {})
  perform_request(__method__, opts)
end

#put(opts = {}) ⇒ Object



27
28
29
# File 'lib/nuvemshop/request.rb', line 27

def put(opts = {})
  perform_request(__method__, opts)
end