Module: RmsItemApi::Item

Includes:
Helper
Included in:
Client
Defined in:
lib/rms_item_api/item/get.rb,
lib/rms_item_api/item/delete.rb,
lib/rms_item_api/item/insert.rb,
lib/rms_item_api/item/update.rb

Constant Summary

Constants included from Helper

Helper::ENDPOINT

Instance Method Summary collapse

Methods included from Helper

#connection, #convert_xml_into_json, #handler

Instance Method Details

#delete(item_data) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/rms_item_api/item/delete.rb', line 5

def delete(item_data)
  request_xml = {itemDeleteRequest: {item: item_data}}.to_xml(
    root: 'request', camelize: :lower, skip_types: true
  )
  response = connection('delete').post {|r| r.body = request_xml}
  handler response
end

#get(item_data) ⇒ Object



5
6
7
8
# File 'lib/rms_item_api/item/get.rb', line 5

def get(item_data)
  response = connection('get').get {|r| r.params['itemUrl'] = item_data}
  handler response
end

#insert(item_data) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/rms_item_api/item/insert.rb', line 5

def insert(item_data)
  request_xml = {itemInsertRequest: {item: item_data}}.to_xml(
    root: 'request', camelize: :lower, skip_types: true
  )
  response = connection('insert').post {|r| r.body = request_xml}
  handler response
end

#update(item_data) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/rms_item_api/item/update.rb', line 5

def update(item_data)
  request_xml = {itemUpdateRequest: {item: item_data}}.to_xml(
    root: 'request', camelize: :lower, skip_types: true
  )
  response = connection('update').post {|r| r.body = request_xml}
  handler response
end