envato-sdk 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1bacaabd361c44b274e342c5e3e9d43faebce08
4
- data.tar.gz: 6d72f24746da821ef6d09dca4575a1084a86b1e4
3
+ metadata.gz: 85318723cad8842630347db996fba2bb15679468
4
+ data.tar.gz: cd6b0c2933e13590c1a2e8400c9754d6693c8507
5
5
  SHA512:
6
- metadata.gz: a2e168def139ca0f70dc2721ad8de842df5a302187490d6711793c6772d2d5ffabb58404032752074470e3b5fa40ab893f655b1b225de3d2b5f91a5d5dbf2810
7
- data.tar.gz: 40184663b24fe489d459139e8422585441bc9b4bfe94f66b6f1d095f8b8b4280b6e713c37c80654391020c69b6665a17bb41414ebc5c216456ae9beac9e8f05d
6
+ metadata.gz: bd76aa40eb91c2c2e7921fa21513b255b9259ac93338155a2a7472064f4f2c58ec6efe76de1fbc64f4228f31a85d4a49c1964c8a2a65e267974b51e8392e6d4a
7
+ data.tar.gz: 7b73db2a5f16b45e86e30ad390d5cba82f5ae9161b318f871ed7bf9af3a40889d9dd7d126f0ac64fd1a8e5af00290c987bc602047d18ab906512e8be3d33ca73
data/README.md CHANGED
@@ -29,17 +29,25 @@ response = client.get 'market/total-users.json'
29
29
  # => {"total-users"=>{"total_users"=>"5942654"}}
30
30
  ```
31
31
 
32
- As this project grows the endpoints will be wrapped in usable methods so instead
33
- of building the request above, you can use the following:
32
+ ## Available endpoints
34
33
 
35
- ```rb
36
- client = Envato::Client.new(access_token: 'mytops3crettoken')
37
- client.total_users
38
- # => 8676143
34
+ Here is a list of the functionality available via this gem. All examples expect
35
+ that you have already created a client called `client` as seen in the above
36
+ example.
39
37
 
40
- # Or maybe...
41
- user_count = Envato::Users.total
42
- ```
38
+ - [total_items](https://build.envato.com/api/#market_TotalItems)
39
+
40
+ ```
41
+ client.total_items
42
+ # => 12345
43
+ ```
44
+
45
+ - [total_users](https://build.envato.com/api/#market_TotalUsers)
46
+
47
+ ```
48
+ client.total_users
49
+ # => 23456
50
+ ```
43
51
 
44
52
  ## Testing
45
53
 
data/lib/envato/client.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  require 'envato/connection'
2
2
  require 'envato/configurable'
3
+ require 'envato/client/stats'
3
4
 
4
5
  module Envato
5
6
  class Client
6
7
 
7
8
  include Envato::Connection
8
9
  include Envato::Configurable
10
+ include Envato::Client::Stats
9
11
 
10
12
  def initialize(options = {})
11
13
  Envato::Configurable.keys.each do |key|
@@ -3,7 +3,12 @@ module Envato
3
3
  module Stats
4
4
  def total_users
5
5
  response = get 'market/total-users.json'
6
- response['total-users']['total_users']
6
+ response['total-users']['total_users'].to_i
7
+ end
8
+
9
+ def total_items
10
+ response = get 'market/total-items.json'
11
+ response['total-items']['total_items'].to_i
7
12
  end
8
13
  end
9
14
  end
@@ -38,7 +38,7 @@ module Envato
38
38
  when 403 then raise Envato::ForbiddenError, extract_forbidden_message(response)
39
39
  when 404 then raise Envato::NotFoundError
40
40
  when 405..499 then raise Envato::ClientError
41
- when 500..599 then raise Envato::ServerError
41
+ when 500..599 then raise Envato::ServerError, extract_server_error_message(response)
42
42
  end
43
43
 
44
44
  begin
@@ -52,5 +52,10 @@ module Envato
52
52
  body = JSON.parse(response.body)
53
53
  body['error_description']
54
54
  end
55
+
56
+ def extract_server_error_message(response)
57
+ body = JSON.parse(response.body)
58
+ body['message']
59
+ end
55
60
  end
56
61
  end
@@ -1,6 +1,6 @@
1
1
  module Envato
2
2
  MAJOR = 0
3
3
  MINOR = 0
4
- PATCH = 4
4
+ PATCH = 5
5
5
  VERSION = [MAJOR, MINOR, PATCH].join '.'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envato-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Bednarz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2015-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler