Method: NationBuilder::Client#raw_call

Defined in:
lib/nationbuilder/client.rb

#raw_call(path, method, body = {}, args = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/nationbuilder/client.rb', line 43

def raw_call(path, method, body = {}, args = {})
  url = NationBuilder::URL.new(base_url).generate_url(path, args)

  request_args = {
    header: {
      'Accept' => 'application/json',
      'Content-Type' => 'application/json'
    },
    query: {
      access_token: @api_key
    }
  }

  if method == :get
    request_args[:query].merge!(body)
  else
    body[:access_token] = @api_key
    if !body[:fire_webhooks].nil?
      request_args[:query][:fire_webhooks] = body[:fire_webhooks]
    end
    request_args[:body] = JSON(body)
  end

  perform_request_with_retries(method, url, request_args)
end