Samanage Ruby Gem

Gem Version Build Status

Requirements

  • Ruby >= 2.3

Installation

gem install samanage

Usage

Basic Queries

Initialize API controller

    api_controller = Samanage::Api.new(token: 'abc123')
  • Create a user

    user = {user: { name: 'John Doe', email: '[email protected]'}}
    api_controller.create_user(payload: user)
    
  • Find a user by email

    my_user = api_controller.find_user_by_email(email: '[email protected]')
    
  • Update incident by ID

    incident_data = {incident: { priority: 'Critical' }}
    incident_update = api_controller.update_incident(id: 123, payload: incident_data)
    
  • Update hardware

    hardware = {hardware: {name: 'My Computer'}}
    result = api_controller.update_hardware(id: 123, payload: hardware)
    

Executing an api query will return a Hash with the following keys:

  • :response: unparsed http response
  • :code: http status code
  • :json: Samanage API json response
  • :headers: Response headers
  • :total_pages: Total pages
  • :total_count: Total count of records
  • :data: Hash containing response body