Citrix

Build Status Code Climate Test Coverage

API wrappers for Citrix services like GoToTraining. It includes partial API mapping for GoToTraining.

Installation

Add this line to your application's Gemfile:

gem 'citrix'

And then execute:

$ bundle

Or install it yourself as:

$ gem install citrix

Usage

GoToTraining

Create client

Initialize a client with provided credentials. The credentials must be a instance of or a Hash accepted by Citrix::Training::Credentials.

client = Citrix::Training::Client.build(
  oauth_token: ENV.fetch('CITRIX_OAUTH_TOKEN'),
  organizer_key: ENV.fetch('CITRIX_ORGANIZER_KEY'),
  account_key: ENV.fetch('CITRIX_ACCOUNT_KEY')
)

Create training

response, training = client.trainings.create({
  name: 'Ruby on Rails',
  description: 'Getting started with Ruby on Rails',
  timezone: 'America/Sao_Paulo',
  dates: [date],
  web_registration: false,
  confirmation_email: false,
  organizers: [organizer]
})

if response.ok?
  # Training successfully created!
else
  p response.data
end

Get all trainings

Retrieve information on all scheduled trainings for a given organizer.

response, trainings = client.trainings.all

if trainings
  # Retrieved all trainings
else
  p response.data
end

Get training

Retrieve information on a given scheduled training for a given organizer.

response, training = client.trainings.find(training_key)

if training
  # Do something with training
else
  p response.data
end

Remove a training

Deletes a scheduled or completed training.

response = client.trainings.remove(training)
response.ok? #=> successfully removed

Add registrant

Register one person, identified by a unique email address, for a training.

response, registrant = client.registrants(training).create({
  first_name: 'John',
  last_name: 'Doe',
  email: '[email protected]'
})

if response.ok?
  # Do something with registrant
else
  p response.data
end

Get all registrants

Retrieve details on all registrants for a specific training.

response, registrants = client.registrants(training).all

if response.ok?
  # Do something with registrants
else
  p response.data
end

Remove registrant

This call cancels a registration in a scheduled training for a specific registrant.

response = client.registrants(training).remove(registrant)
response.ok? #=> successfully removed

Contributing

  1. Fork it ( https://github.com/fnando/citrix/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request