Git Product home page Git Product logo

ruby-client's Introduction

Namely

Codacy Badge Codacy Badge Travis Code Climate

The Namely gem wraps the Namely HTTP API, allowing you to manipulate your account through Ruby.

Installation

Add this line to your application's Gemfile:

gem "namely"

And then execute:

$ bundle

Or install it yourself as:

$ gem install namely

Establishing a connection

First, you'll need to create a connection to your Namely account using your access token and subdomain.

namely = Namely::Connection.new(
  access_token: "your_access_token",
  subdomain: "your-organization",
)

An access token can be obtained through your organization's Namely account.

Namely associates a subdomain with your organization. For example, if your account is at http://your-organization.namely.com/, your subdomain would be "your-organization".

Configuration

You can override default configuration using Namely.configuration like:

Namely.configuration do |config|

  # While returning paged results, which http codes should be rescued and
  # retried? Defaults to none.
  config.http_codes_to_retry = [504] # gateway timeout

  # The number of times to retry the requests rescued above. Default is 0
  config.retries = 2
end

Usage Examples

Once you've created a connection you can use it to access your data.

namely.countries.all.each do |country|
  puts "#{country.id} - #{country.name}"
end
# AF - Afghanistan
# AL - Albania
# DZ - Algeria
# AS - American Samoa
# ...
if namely.countries.exists?("BE")
  "Belgium exists!"
else
  "Hmm."
end # => "Belgium exists!"
namely.countries.find("BE")
# => <Namely::Model id="BE", name="Belgium", subdivision_type="Province", links={"subdivisions"=>[{"id"=>"BRU", "name"=>"Brussels"}, {"id"=>"VAN", "name"=>"Antwerpen (nl)"}, {"id"=>"VBR", "name"=>"Vlaams Brabant (nl)"}, {"id"=>"VLI", "name"=>"Limburg (nl)"}, {"id"=>"VOV", "name"=>"Oost-Vlaanderen (nl)"}, {"id"=>"VWV", "name"=>"West-Vlaanderen (nl)"}, {"id"=>"WBR", "name"=>"Brabant Wallon (fr)"}, {"id"=>"WHT", "name"=>"Hainaut (fr)"}, {"id"=>"WLG", "name"=>"Liège (fr)"}, {"id"=>"WLX", "name"=>"Luxembourg (fr)"}, {"id"=>"WNA", "name"=>"Namur (fr)"}]}>
foo_bar = namely.profiles.create!(
  first_name: "Dade",
  last_name: "Murphy",
  email: "[email protected]"
)

foo_bar.id # => "37c919e2-f1c8-4beb-b1d4-a9a36ccc830c"

Contributing

Wanna help out? Great! Here are a few resources that might help you started:

Setting up a development environment

After you have cloned this repo, run this setup script to set up your machine with the necessary dependencies to run and test this app:

% ./bin/setup

The Namely gem uses dotenv to manage environment variables. Visit the .env file and change a plug in appropriate values:

TEST_ACCESS_TOKEN=my-sample-access-token
TEST_SUBDOMAIN=my-sample-subdomain

You'll need admin access to a Namely site to get tokens for these variables. You can create application and permanent tokens on the API page of the site.

Submitting your changes

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am "Add some feature"). Be sure to include tests!
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new pull request. We'll review it and leave feedback for you ASAP.

ruby-client's People

Contributors

bobbytables avatar carlosplusplus avatar dthagard avatar georgebrock avatar hrs avatar klcrow avatar macat avatar mike-burns avatar ncherro avatar nnarh avatar rreinhardt9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-client's Issues

Working with client identifier and client secret?

It seems like your Auth documentation recommends against using the permanent access token, but it doesn't appear that your gem supports any other method. Any clarification on why it doesn't support client identifier and secret as well as permanent access token?

RubyGems 2.4.5 raises warning about `rest_client`

The following warning is raised when using the Ruby Client in a project while on Ruby Gems 2.4.5:

WARNING: The rest_client gem is deprecated and will be removed from RubyGems. Please use rest-client gem instead.

504 GatewayTimeout returned while retrieving paged profiles

While using connection.profiles.all occasionally the namely API will return a 504 gateway timeout status while retrieving one of the pages. This raises an exception and derails the (sometimes lengthy) process of retrieving all of the paged results.

One possible solution would be to catch that exception and retry a few times before returning the error. PR example solution forthcoming...

Drop backports / old rubies?

Using Ruby 2.4.0, our Rails app spits out warnings from the backports gem, which is required by the namely gem:

/Users/oli/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/backports-3.6.8/lib/backports/1.8.7/fixnum/div.rb:1: warning: constant ::Fixnum is deprecated
/Users/oli/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/backports-3.6.8/lib/backports/1.8.7/fixnum/fdiv.rb:1: warning: constant ::Fixnum is deprecated
/Users/oli/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/backports-3.6.8/lib/backports/2.1.0/bignum/bit_length.rb:1: warning: constant ::Bignum is deprecated
/Users/oli/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/backports-3.6.8/lib/backports/2.1.0/fixnum/bit_length.rb:1: warning: constant ::Fixnum is deprecated

Looking at this repo I noticed the travis.yml also uses old version of Ruby:

rvm:
  - 1.9.3
  - jruby-19mode
  - 2.0.0
  - 2.1.3

Ruby 1.9.3 and 2.0.0 have now reached end-of-life status. Could they be dropped, along with backports?

stripe gem conflict

Im having a dependency conflict with rest_client and netrc via stripe. full error report is below. would bumping the rest-client version dependency up be possible?

    Bundler could not find compatible versions for gem "netrc":
      In Gemfile:
        namely (>= 0) ruby depends on
          rest_client (>= 0) ruby depends on
            netrc (~> 0.7.7) ruby

        stripe (>= 0) ruby depends on
          rest-client (~> 1.4) ruby depends on
            netrc (0.10.2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.