No release in over 3 years
Low commit activity in last 3 years
Ruby client for Noko API. #ruby #client #nokotime
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Nokotime

Ruby client for Noko API.

Build Status Test Coverage Maintainability

Installation

Add this line to your application's Gemfile:

gem 'nokotime-ruby-client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nokotime-ruby-client

Usage

  1. Configure .env file. You must define the NOKOTIME_TOKEN environment variable with your Nokotime API token.

E.g.

NOKOTIME_TOKEN=123921387213987132987
  1. Configure client with:
Nokotime.configure do |c|
  c.token = ENV["NOKOTIME_TOKEN"]
  c.auth_type = :noko_token
  c.max_concurrency = 5
end

You can set:

  1. auth_type: the authentication type which will use with the server. Currently, the only allowed values is:
    • :noko_token: uses your Nokotime API token.
  2. max_concurrency: max thread for each requests.

You can initialize each client with some query parameters (only for #all method):

  • Entry: user_ids, description, project_ids, tag_ids, tag_filter_type, invoice_ids import_ids, from, to, invoiced, invoiced_at_from, invoiced_at_to updated_from, updated_to, billable, approved_at_from, approved_at_to approved_by_ids, per_page;
  • Project: name, project_group_ids, billing_increment, enabled, billable, per_page;
  • ProjectGroup: name, project_ids, per_page;
  • Tag: name, billable, per_page;
  • User: name, email, role, state, per_page;

Example

users = Nokotime::Client::Users.new({name: "my_name"}).all
users.last_responses.each do |resp|
  resp.body
end

Testing

The test suite uses the VCR gem.

The contents of the cassettes is anonymized (see spec/spec_helper.rb).

Regenerating the VCR cassettes

Occasionally, it is a good idea to regenerate the cassettes in order to do an end-to-end test.

Make sure you have correctly set the .env.test file. Inside this file you must specify the keys:

  • NOKOTIME_TOKEN: your Nokotime API token;
  • REAL_NOKOTIME_ENTRY_ID: a real entry id.
  • REAL_NOKOTIME_PROJECT_ID: a real project id.
  • REAL_NOKOTIME_USER_ID: a real user id.
$ rm -rf spec/fixtures/vcr_cassettes/*
$ bundle
$ bundle exec rspec

Supported Ruby Versions

This library is tested against the following Ruby implementations:

  • Ruby 2.4
  • Ruby 2.5
  • Ruby 2.6

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sirion1987/nokotime-ruby-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Nokotime::Ruby::Client project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.