Module: SilencerShop::API

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

Constant Summary collapse

USER_AGENT =
"SilencerShopRubyGem/#{SilencerShop::VERSION}".freeze
API_URL =
{
  development: 'https://silencershopportaldebug.azurewebsites.net/api'.freeze,
  production:  'https://silencershopportal.azurewebsites.net/api'.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



16
17
18
19
20
# File 'lib/silencer_shop/api.rb', line 16

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



28
29
30
31
32
# File 'lib/silencer_shop/api.rb', line 28

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



22
23
24
25
26
# File 'lib/silencer_shop/api.rb', line 22

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