= SalesKing API Client ActiveResource based SalesKing API client. This client does not uses oAuth2 yet, it still uses HTTBasic Auth with username and password. This does NOT rely on parsing the JSON Schema, since ActiveResource creates the Getter/Setter methods(less restrict). The client also adds some patches to AR to fix json parsing issues. == Install gem install sk_sdk Dependencies (gem's): * activeresupport * activeresource == Usage SalesKing's api interface is RESTful(mostly) and returns & accepts JSON data. All resources such as clients, invoices, products can be accessed via URL's through standard HTTP methods GET, POST, PUT and DELETE. see available objects and endpoints here: https://github.com/salesking/sk_api_schema/tree/master/json First create the classes: require "sk_sdk/ar_client" SK::SDK::ArCli.make(:client) # Create class within namespace module; King; end SK::SDK::ArCli.make(:credit_note, King) Now the classes are available they need connection settings first. Those Must be set for each class separate and you MUST provide the full url using the right protocol http/https + SUBDomain + salesking url + /api Our production system only supports HTTPS. [Client, CreditNote].each do |i| i.send(:set_connection, {:site => 'https://my_sub.salesking.eu/api', :user => 'my-users@login-email.com', :password => 'password' }) client = Client.new(:last_name=> 'Meister') client.first_name = "Bau" client.save credit_note = King::CreditNote.new Also see ActiveResource readme: https://github.com/rails/rails/tree/master/activeresource Want to know more about REST style webservices? * http://en.wikipedia.org/wiki/Representational_State_Transfer * http://www.google.com/search?q=REST+site%3Awww.infoq.com === Authentification & Safety Authentification can be done with oAuth2 but this client still uses HTTP basic using your SalesKing login email and password. For a production environment be advised to create a user, per api client, and restrict his rights with our build in role-system! === API Tutorial and Tools Since browsers do not support PUT/DELETE methods you can use CURL, a linux command-line http client, for testing. And of course any http library supporting http-basic-auth can be used. * Getting started: http://dev.blog.salesking.eu/api/ * Chrome cRest extension https://chrome.google.com/extensions/detail/baedhhmoaooldchehjhlpppaieoglhml * Poster FF-Plugin - make HTTP request https://addons.mozilla.org/en-US/firefox/addon/2691/ (you must be logged into SalesKing) * JSONView FF-Plugin - view json in firefox https://addons.mozilla.org/de/firefox/addon/10869/ * JSONovich FF-Plugin - https://addons.mozilla.org/de/firefox/addon/10122/ == Tests / Specs Take a look into spec/resources to see a how-to rake coverage Copyright (c) 2011 Georg Leciejewski, released under the MIT license