Ucb::Hcm

Ucb::Hcm is a lightweight ruby wrapper around UC Berkeley's Human Capital Management API.

Version 1.0 of this gem supports the v2 API, documented in the link above. UCB now has v3 of the API - we'll skip version 2.0 of the gem and make version 3.0 support the v3 API.

Installation

Add this line to your application's Gemfile:

gem 'ucb-hcm', "~> 3"

And then execute:

$ bundle

Or install it by yourself:

$ gem install ucb-hcm

Configuration

Configure your app with your API credentials from UCB's API Central.

Ucb::Hcm.configure do |hcm|
  hcm.app_id  = "APP_ID"
  hcm.app_key = "APP_KEY"
  hcm.endpoint = "https://apis.berkeley.edu/dev/hr/v3"
end

Usage

:rotating_light: Note: Version 3.x of this gem only supports v3 of the API. :rotating_light:

Fetch Employees

    client = Ucb::Hcm::Client.new
    response = client.get("/employees", { limit: 20, previous: 0, next: 20 })

    >> response.data
    => [
          {
            "identifiers"=> [
                {"type"=>"hr-employee-id", "id"=>"10141478"}
            ]
          },
          {
            "identifiers"=>[
                {"type"=>"hr-employee-id", "id"=>"10272831"},
                {"type"=>"legacy-hr-employee-id", "id"=>"12521372"}
            ]
          }
          ...
        ]

Fetch specific Employee

    client = Ucb::Hcm::Client.new
    response = client.get("/employees/10272831", {"id-type" => "hr-employee-id"})

    >> response.data
    => {
          "identifiers" => [
            {"type" => "campus-uid", "id" => "20108691"}, {"type" => "campus-solutions-id"}, {"type" => "student-id"}, {"type" => "hr-employee-id", "id" => "10272831"}, {"type" => "legacy-hr-employee-id"}, {"type" => "calnet-id"}
          ],
          "names" => [{
            "type "= >{"code" => "PRI", "description" => "Primary"},
            "familyName" => "Kumar",
            "givenName" => "Siri",
            "lastChangedBy" => {"id" => "10000499"},
            "fromDate" => "2018-10-01"
          }],
          ...
        }

Fetch an Employee's jobs

    client = Ucb::Hcm::Client.new
    response = client.get("/employees/10272831/jobs", {"id-type" => "hr-employee-id"})

    # The jobs api sometimes returns an array with the first element
    # containing the real job data and the second an empty hash :(.
    # For example: [{<real_data>}, {}]
    >> response.data.first["jobs"]
    => [
        {
          "number" => 0,
          "sequence" => 0,
          "type" => {
            "code" => "2",
            "description" => "Staff: Career"
          },
          ...
        }
    ]

Contributing

  1. Fork it ( https://github.com/[my-github-username]/ucb-hcm/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Ask for .env file from previous developer and run source .env
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request