readme.markdown in credly-0.0.1 vs readme.markdown in credly-0.0.2

- old
+ new

@@ -1,76 +1,62 @@ # A Ruby client for the Credly API Credly is an Badging service. This is the the API client for the ruby client. You can find Credly's API at https://apidocs2.credly.com/credly. -# Configuration +## Install -This is how you can configure the default values for Credly: - -```ruby -Credly.configuration do |config| - # These are the default values - config.base_endpoint = 'apistaging2.credly.com' - config.version = 'v0.2' - config.auth_token = nil -end ``` +gem 'credly' +``` -You can also: - +## Quick Start ```ruby -Credly.configuration.base_endpoint = 'apistaging2.credly.com/v0.2/' -Credly.configuration.version = 'v0.2' -Credly.configuration.auth_token = nil +client = Credly::Client.new(access_token: '26287568342') +# Or +client = Credly::Client.new(username: 'whatever', password: 'mypass') + +client.badges.all +client.badges.find(1) +client.badges.categories.all ``` -Those options will be the default ones for any `client.api` you create afterwards. Nonetheless, you can overwrite any of these options; just pass it as an argument when you instantiate the client: +All API endpoints are accessible from the client instance. The endpoints methods are named after the remote endpoint. So, for example any action on 'https://apistaging2.credly.com/v0.2/members' will be using `client.members`. -```ruby -client = client.api.new(auth_token: '26287568342') +Nested endpoints, like `/members/:id/badges` are also nested in the client +```ruby +client.members(id).badges.all(other_parameter: 'whatever') ``` -Then you instantiate a client and use it to make calls: -```ruby -client = client.api.new() +Check https://github.com/haikulearning/credly-ruby/blob/master/spec/unit/api_spec.rb for examples. -client.api.badges.all -=> #<OpenStruct - meta={"status_code"=>200, "status"=>"OK", "message"=>"", "more_info"=>nil}, - data=[ - { "id"=>1003, - "title"=>"asadas", - "short_description"=>"asdasda", - "image_url"=>"https://credlyapp.s3.amazonaws.com/badges/6f7791d21e13ca7409146c2343fdf28d.png", - "is_giveable"=>false, - "created_at"=>"Thu, 04 Jul 2013 06:33:43 -0400", - "creator_id"=>147, - "resources"=>{"url"=>"https://apistaging2.credly.com/v0.2/badges/1003"}}, - { "id"=>1002, - "title"=>"asadas", - "short_description"=>"asdasda", - "image_url"=>"https://credlyapp.s3.amazonaws.com/badges/6f7791d21e13ca7409146c2343fdf28d.png", - "is_giveable"=>false, - "created_at"=>"Thu, 04 Jul 2013 06:31:46 -0400", - "creator_id"=>147, - "resources"=>{"url"=>"https://apistaging2.credly.com/v0.2/badges/1002"}} - ] - > +## Configuration +This is how you can configure the default values for Credly: + +```ruby +Credly.configuration do |config| + # These are the default values + config.base_endpoint = 'apistaging2.credly.com' + config.version = 'v0.2' + config.access_token = nil +end ``` -All API endpoints are accessible from `client.api`. The endpoints methods are named after the remote endpoint. So, for example any action on 'https://apistaging2.credly.com/v0.2/members' will be using `client.api.members`. +You can also do: -Nested endpoints, like `/members/:id/badges` are also nested in the client - ```ruby -client.api.members.badges +Credly.configuration.base_endpoint = 'apistaging2.credly.com/v0.2/' +Credly.configuration.version = 'v0.2' +Credly.configuration.access_token = nil ``` -In those cases, the `id` will be the first parameter on the method, as in: +Those options will be the default ones for any `client` you create afterwards. Nonetheless, you can overwrite any of these options; just pass it as an argument when you instantiate the client: + ```ruby -client.api.members.badges.all(1, { other_parameter: 'whatever' }) +client = Credly::Client.new(access_token: '26287568342', base_endpoint: 'apistaging2.credly.com/', version: 'v0.2') ``` -Check https://github.com/haikulearning/credly-ruby/blob/master/spec/unit/api_spec.rb for examples. \ No newline at end of file +## License & Acknowledgments + +The MIT License, for full details please see the LICENSE file.