Class: ITGlue::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/itglue/client.rb,
lib/itglue/client/mapper.rb,
lib/itglue/client/path_processor.rb

Defined Under Namespace

Classes: Mapper, PathProcessor

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.

Raises:



14
15
16
17
18
19
20
21
# File 'lib/itglue/client.rb', line 14

def initialize
  raise ClientError.new('itglue_api_key not configured') unless ITGlue.config.itglue_api_key
  raise ClientError.new('itglue_api_base_uri not configured') unless ITGlue.config.itglue_api_base_uri
  @itglue_api_key    = ITGlue.config.itglue_api_key
  @default_page_size = ITGlue.config.default_page_size
  self.class.base_uri  ITGlue.config.itglue_api_base_uri
  self.class.logger    ITGlue.config.logger
end

Instance Method Details

#execute(http_method, path, payload = nil, options = {}) ⇒ Object



23
24
25
# File 'lib/itglue/client.rb', line 23

def execute(http_method, path, payload = nil, options = {})
  process_request(http_method, path, payload, options)
end

#get(asset_type, path_options = {}, options = {}) ⇒ Object



27
28
29
30
31
# File 'lib/itglue/client.rb', line 27

def get(asset_type, path_options = {}, options = {})
  response = process_request(:get, process_path(asset_type, path_options), nil, options)
  data = get_remaining_data(response, options)
  prepare_data(data)
end

#patch(asset_type, payload, path_options = {}, options = {}) ⇒ Object



33
34
35
36
# File 'lib/itglue/client.rb', line 33

def patch(asset_type, payload, path_options = {}, options = {})
  response = process_request(:patch, process_path(asset_type, path_options), payload, options)
  prepare_data(response['data'])
end

#post(asset_type, payload, path_options = {}, options = {}) ⇒ Object



38
39
40
41
# File 'lib/itglue/client.rb', line 38

def post(asset_type, payload, path_options = {}, options = {})
  response = process_request(:post, process_path(asset_type, path_options), payload, options)
  prepare_data(response['data'])
end