Class: Concessions_api

Inherits:
Object show all
Defined in:
lib/concessions_api.rb

Class Method Summary collapse

Class Method Details

.create_concession_order(location_id, api_key, body, opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/concessions_api.rb', line 11

def self.create_concession_order (location_id,api_key,body,opts={})
  query_param_keys = [:api_key]

  # verify existence of params
  raise "location_id is required" if location_id.nil?
  raise "api_key is required" if api_key.nil?
  raise "body is required" if body.nil?
  # set default values and merge with input
  options = { :location_id => location_id, :api_key => api_key, :body => body}.merge(opts)

  #resource path
  path = "/concessions/{location_id}/order".sub('{format}','json').sub('{' + 'location_id' + '}', escapeString(location_id))
  
  
  # pull querystring keys from options
  queryopts = options.select do |key,value|
    query_param_keys.include? key
  end
  
  headers = nil
  post_body = nil
  if body != nil
    if body.is_a?(Array)
      array = Array.new
      body.each do |item|
        if item.respond_to?("to_body".to_sym)
          array.push item.to_body
        else
          array.push item
        end
      end
      post_body = array

    else 
      if body.respond_to?("to_body".to_sym)
       post_body = body.to_body
     else
       post_body = body
     end
    end
  end
  response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
  ConcessionOrderResults.new(response)
end

.escapeString(string) ⇒ Object

apiInvoker = APIInvoker



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

def self.escapeString(string)
  URI.encode(string.to_s)
end