Class: EloquaApiService::Service

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/eloqua_api_service/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(account: nil) ⇒ Service

Returns a new instance of Service.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/eloqua_api_service/service.rb', line 9

def initialize(account: nil)
  @credentials = Credential.new.find(account: )

  self.class.base_uri @credentials.service

  @options = { headers: {
    'Authorization' => "Basic #{@credentials.password}",
    'Content-Type' => 'application/json'
    },
    body: {}
  }
end

Instance Method Details

#parse(response) ⇒ Object



22
23
24
# File 'lib/eloqua_api_service/service.rb', line 22

def parse(response)
  JSON.parse(response.body, symbolize_names: true)
end

#parse_body(body) ⇒ Object



26
27
28
# File 'lib/eloqua_api_service/service.rb', line 26

def parse_body(body)
  JSON.parse(body, symbolize_names: true)
end