README.rdoc in 3scale_client-2.2.7 vs README.rdoc in 3scale_client-2.2.8
- old
+ new
@@ -4,17 +4,23 @@
This library is distributed as a gem:
gem install 3scale_client
-Or alternatively, download the source code from github:
+Or alternatively, download the source code from github:
http://github.com/3scale/3scale_ws_api_for_ruby
-If you are using Rails, put this into your config/environment.rb
+If you are using Bundler, please add this to your Gemfile:
- config.gem "3scale_client"
+ gem '3scale_client', :require => '3scale/client'
+and do a bundle install.
+
+If you are using Rails' config.gems, put this into your config/environment.rb
+
+ config.gem "3scale_client", :lib => '3scale/client'
+
Otherwise, require the gem in whatever way is natural to your framework of choice.
== Usage
First, create an instance of the client, giving it your provider API key:
@@ -26,11 +32,11 @@
=== Authorize
To authorize an application, call the +authorize+ method passing it the application's id and
optionally a key:
- response = client.authorize(:app_id => "the app id", :app_id => "the app key")
+ response = client.authorize(:app_id => "the app id", :app_key => "the app key")
Then call the +success?+ method on the returned object to see if the authorization was
successful.
if response.success?
@@ -66,16 +72,27 @@
usage_report.max_value # 10000
# If the limit is exceeded, this will be true, otherwise false:
usage_report.exceeded? # false
-If the authorization failed, the +error_code+ returns system error code and +error_message+
+If the authorization failed, the +error_code+ returns system error code and +error_message+
human readable error description:
-
+
response.error_code # "usage_limits_exceeded"
response.error_message # "Usage limits are exceeded"
+=== OAuth Authorize
+
+To authorize an application with OAuth, call the +oauth_authorize+ method passing it the application's id.
+
+ response = client.authorize(:app_id => "the app id")
+
+If the authorization is successful, the response will contain the +app_key+ and +redirect_url+ defined for this application:
+
+ response.app_key
+ response.redirect_url
+
=== Report
To report usage, use the +report+ method. You can report multiple transaction at the same time:
response = client.report({:app_id => "first app id", :usage => {'hits' => 1}},
@@ -91,10 +108,10 @@
"quacks" like it (for example, the ActiveSupport::TimeWithZone from Rails) or a string. The
string has to be in a format parseable by the Time.parse method. For example:
"2010-04-28 12:38:33 +0200"
-If the timestamp is not in UTC, you have to specify a time offset. That's the "+0200"
+If the timestamp is not in UTC, you have to specify a time offset. That's the "+0200"
(two hours ahead of the Universal Coordinate Time) in the example abowe.
Then call the +success?+ method on the returned response object to see if the report was
successful.