al_papi 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/README.md +38 -1
  2. metadata +5 -5
data/README.md CHANGED
@@ -44,7 +44,8 @@ Post your keyword to the priority queue if you need results in a more timely man
44
44
  ### GET
45
45
 
46
46
  When you are ready to get your results you can do a GET request for your keyword-engine-locale combo:
47
- res = req.post keyword: "Mad Scientist", engine: 'bing', locale: 'en-ca'
47
+
48
+ res = req.get keyword: "Mad Scientist", engine: 'bing', locale: 'en-ca'
48
49
 
49
50
  if res.success?
50
51
  p 'Canadian Bing Scientist Time'
@@ -53,6 +54,42 @@ When you are ready to get your results you can do a GET request for your keyword
53
54
  p 'PAPI Fail'
54
55
  end
55
56
 
57
+ ### Response
58
+
59
+ When making an API request a response object is returned with any errors, http response code and http reponse body.
60
+
61
+ res = req.get keyword: "Mad Scientist", engine: 'bing', locale: 'en-ca'
62
+
63
+ # Errors:
64
+ # Returns an array of error objects.
65
+ res.errors
66
+
67
+ if res.errors.present?
68
+ res.errors.each do |error|
69
+ p error.code # http repsonse code
70
+ p error.message # error message
71
+ p error.params # params of request
72
+ p error.path # path of request
73
+ end
74
+ end
75
+
76
+ # Success:
77
+ # Returns true or false if request was successful or not.
78
+ res.success?
79
+
80
+ # Body:
81
+ # Returns body of response.
82
+ # On GET requests the body will be a hash of your results if successful.
83
+ res.body
84
+
85
+ # Code:
86
+ # Returns http response code.
87
+ # 204: On GET requests when no data is available yet
88
+ # 200: Successful
89
+ # 401: Invalid api key
90
+ # 500: Server Error
91
+ res.code
92
+
56
93
  ### Engines
57
94
 
58
95
  Supported engines are Google, Yahoo and Bing. To get a list of supported engines run the following:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: al_papi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &70322318185480 !ruby/object:Gem::Requirement
16
+ requirement: &70201333396700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.6.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70322318185480
24
+ version_requirements: *70201333396700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70322318184620 !ruby/object:Gem::Requirement
27
+ requirement: &70201333395880 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '2.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70322318184620
35
+ version_requirements: *70201333395880
36
36
  description: Wraps AuthorityLabs Partner API calls in a gem.
37
37
  email: ''
38
38
  executables: []