envato-sdk 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -9
- data/lib/envato/client.rb +2 -0
- data/lib/envato/client/stats.rb +6 -1
- data/lib/envato/connection.rb +6 -1
- data/lib/envato/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85318723cad8842630347db996fba2bb15679468
|
4
|
+
data.tar.gz: cd6b0c2933e13590c1a2e8400c9754d6693c8507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
33
|
-
of building the request above, you can use the following:
|
32
|
+
## Available endpoints
|
34
33
|
|
35
|
-
|
36
|
-
client
|
37
|
-
|
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
|
-
|
41
|
-
|
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|
|
data/lib/envato/client/stats.rb
CHANGED
@@ -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
|
data/lib/envato/connection.rb
CHANGED
@@ -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
|
data/lib/envato/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|