0.0
No release in over 3 years
Low commit activity in last 3 years
Knackhq.com API client
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
~> 3.2.0
~> 1.2.0
~> 0.9.0
~> 2.9.0
~> 1.20.0

Runtime

 Project Readme

Knackhq::Client

Gem Version Build Status Dependency Status Code Climate

Installation

Add this line to your application's Gemfile:

gem 'knackhq-client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install knackhq-client

Usage

api = Knackhq::Client.new('knack-api-url',
                    x_knack_application_id,
                    x_knack_rest_api_key)

#GET all objects in api.
api.objects
#Output:
[{:name=>"Foo", :key=>"object_1"}
{:name=>"Bar", :key=>"object_2"}]

#GET object_1 fields
api.fields('object_1')
#Output:
[{:label=>"Number", :key=>"field_1", :type=>"float", :required=>false, :field_type=>"number"},
{:label=>"Last Date", :key=>"field_12", :type=>"datetime", :required=>false, :field_type=>"date_time"}]

#GET object_1 records
api.records('object_1')
#Output:
{:total_pages=>2, :current_page=>1, :total_records=>28, :records=>[{:id=>"23456", :account_status=>"active", :approval_status=>"approved", :profile_keys=>"Bar", :profile_keys_raw=>[{:id=>"12345", :identifier=>"Bar"}], :field_32=>"First Name", :field_32_raw=>{:last=>"Last", :first=>"First"}, :field_33=>"<a href=\"mailto:flast@example.com\">flast@example.com</a>", :field_33_raw=>{:email=>"flast@example.com"}, :field_34=>"*********", :field_34_raw=>"**********", :field_188=>"<span class=\"23456\">Bar</span>", :field_188_raw=>[{:id=>"23456", :identifier=>"Bar"}]}]}

#GET object_1 record
#Knackhq record ID is 12345
api.update_record('object_1', '12345')

#GET object_1
api.object('object_1')
#Output
{:id=>"34567", :default=>"", :key=>"field_1", :name=>"Foo", :rules=>[], :conditional=>false, :user=>false, :unique=>true, :required=>true, :immutable=>false, :type=>"short_text"}

#PUT object_1 record
#Knackhq ID is 12345
api.update_record('object_1', '12345', { field_name: value }.to_json)
#Output:
true/false

Contributing

  1. Fork it ( https://github.com/[my-github-username]/knackhq-client/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