Module: SilencerShop::API

Included in:
Client, Dealer, Order, ProductFeed
Defined in:
lib/silencer_shop/api.rb

Constant Summary collapse

ROOT_API_URL =
'https://silencershopportaldebug.azurewebsites.net/api'.freeze
USER_AGENT =
"SilencerShopRubyGem/#{SilencerShop::VERSION}".freeze
FILE_UPLOAD_ATTRS =
{
  permitted: i( file_name file_type file_contents ).freeze,
  reqired:   i( file_type file_contents ).freeze,
}

Instance Method Summary collapse

Instance Method Details

#get_request(endpoint, headers = {}, root_url = nil) ⇒ Object



14
15
16
17
18
# File 'lib/silencer_shop/api.rb', line 14

def get_request(endpoint, headers = {}, root_url = nil)
  request = Net::HTTP::Get.new(request_url(endpoint, root_url))

  submit_request(request, {}, headers)
end

#post_file_request(endpoint, file_data, headers = {}, root_url = nil) ⇒ Object



26
27
28
29
30
# File 'lib/silencer_shop/api.rb', line 26

def post_file_request(endpoint, file_data, headers = {}, root_url = nil)
  request = Net::HTTP::Post.new(request_url(endpoint, root_url))

  submit_file_request(request, file_data, headers)
end

#post_request(endpoint, data = {}, headers = {}, root_url = nil) ⇒ Object



20
21
22
23
24
# File 'lib/silencer_shop/api.rb', line 20

def post_request(endpoint, data = {}, headers = {}, root_url = nil)
  request = Net::HTTP::Post.new(request_url(endpoint, root_url))

  submit_request(request, data, headers)
end