envato-sdk 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85318723cad8842630347db996fba2bb15679468
4
- data.tar.gz: cd6b0c2933e13590c1a2e8400c9754d6693c8507
3
+ metadata.gz: 161e6a8f05ab1d5cd4085bbfa404d043fcc468d5
4
+ data.tar.gz: 3f24c8df1c6018e93c3ba47716cdfe279505d94b
5
5
  SHA512:
6
- metadata.gz: bd76aa40eb91c2c2e7921fa21513b255b9259ac93338155a2a7472064f4f2c58ec6efe76de1fbc64f4228f31a85d4a49c1964c8a2a65e267974b51e8392e6d4a
7
- data.tar.gz: 7b73db2a5f16b45e86e30ad390d5cba82f5ae9161b318f871ed7bf9af3a40889d9dd7d126f0ac64fd1a8e5af00290c987bc602047d18ab906512e8be3d33ca73
6
+ metadata.gz: e2ad00c1d5d6d43e930afbde208ecd46027c67966666810aab9c635f65941d87e010db71636e80cf97fa25646eccaf8cf5e64226b4fe67f9cea3727b7d2de970
7
+ data.tar.gz: 01a0f5e0fe558024a1886b3d4aa7c2a52ba92265e1a39ed02bae3de5fef4b8c8514771562dc1fe23b7dac3476f435af45d258ab700ae615bca2799671762184e
data/README.md CHANGED
@@ -29,26 +29,87 @@ response = client.get 'market/total-users.json'
29
29
  # => {"total-users"=>{"total_users"=>"5942654"}}
30
30
  ```
31
31
 
32
- ## Available endpoints
32
+ ## Examples
33
33
 
34
34
  Here is a list of the functionality available via this gem. All examples expect
35
35
  that you have already created a client called `client` as seen in the above
36
- example.
36
+ example. `...` represents multiple of the previous item repeated such as a hash
37
+ or array item.
37
38
 
38
- - [total_items](https://build.envato.com/api/#market_TotalItems)
39
+ #### User
39
40
 
41
+ - [`account_details`](https://build.envato.com/api/#market_Account)
42
+
43
+ ```rb
44
+ client.account_details
45
+ # => {"image"=>"https://0.s3.envato.com/files/144155428/avatar.jpg", "firstname"=>"Jacob", "surname"=>"Bednarz", "available_earnings"=>"0.00", "total_deposits"=>"0.00", "balance"=>"0.00", "country"=>"Australia"}
46
+ ```
47
+
48
+ - [`username`](https://build.envato.com/api/#market_Username)
49
+
50
+ ```rb
51
+ client.username
52
+ # => 'jacobbednarz'
53
+ ```
54
+
55
+ - [`email_address`](https://build.envato.com/api/#market_Email)
56
+
57
+ ```rb
58
+ client.email_address
59
+ # => 'jacob@envato.com'
60
+ ```
61
+
62
+ - [`user_information`](https://build.envato.com/api/#market_User)
63
+
64
+ ```rb
65
+ client.user_information('jacobbednarz')
66
+ # => {"username": "jacobbednarz","country": "Australia","sales": "0","location": "","image": "https://0.s3.envato.com/files/144155428/avatar.jpg","followers": "4"}
67
+ ```
68
+
69
+ - [`badges_for_user`](https://build.envato.com/api/#market_UserBadges)
70
+
71
+ ```rb
72
+ client.badges_for_user('jacobbednarz')
73
+ # => [{"name"=>"country_au", "label"=>"Australia", "image"=>"https://dmypbau5frl9g.cloudfront.net/assets/badges/country_au-53dc340a932f5b9f1d1db574fb6712b4.svg"}, {"name"=>"envato_team", "label"=>"Envato Team", "image"=>"https://dmypbau5frl9g.cloudfront.net/assets/badges/envato_team-ac987db51c92549046fa25dfb7259bf9.svg"}, {"name"=>"exclusive", "label"=>"Exclusive Author", "image"=>"https://dmypbau5frl9g.cloudfront.net/assets/badges/exclusive-f7d9bbcda891f9ad25f00da4ea099435.svg"}]
40
74
  ```
75
+
76
+ - [`user_items_by_site`](https://build.envato.com/api/#market_UserItemsBySite)
77
+
78
+ ```rb
79
+ client.user_items_by_site('collis')
80
+ # => [{"site"=>"ThemeForest", "items"=>"1"}, {"site"=>"Tuts+ Marketplace", "items"=>"2"}]
81
+ ```
82
+
83
+ - [`new_items_for_user`](https://build.envato.com/api/#market_NewFilesFromUser)
84
+
85
+ ```rb
86
+ client.new_items_for_user('collis', 'themeforest')
87
+ # => [{"id"=>"22705", "item"=>"Black + White Simple Theme", "url"=>"http://themeforest.net/item/black-white-simple-theme/22705", "user"=>"collis", "thumbnail"=>"https://preview-tf.s3.envato.com/files/60223.jpg", "sales"=>"916", "rating"=>"4.5", "rating_decimal"=>"4.32", "cost"=>"8.00", "uploaded_on"=>"Tue Dec 02 04:01:12 +1100 2008", "last_update"=>"", "tags"=>"clean", "category"=>"psd-templates/creative", "live_preview_url"=>"https://0.s3.envato.com/files/60224/1_home.__large_preview.jpg"}]
88
+ ```
89
+
90
+ #### Marketplace Stats
91
+
92
+ - [`total_items`](https://build.envato.com/api/#market_TotalItems)
93
+
94
+ ```rb
41
95
  client.total_items
42
96
  # => 12345
43
97
  ```
44
98
 
45
- - [total_users](https://build.envato.com/api/#market_TotalUsers)
99
+ - [`total_users`](https://build.envato.com/api/#market_TotalUsers)
46
100
 
47
- ```
101
+ ```rb
48
102
  client.total_users
49
103
  # => 23456
50
104
  ```
51
105
 
106
+ - [`category_information_by_site`](https://build.envato.com/api/#market_NumberOfFiles)
107
+
108
+ ```rb
109
+ client.category_information_by_site('themeforest')
110
+ # => [{"category"=>"Site Templates","number_of_files"=>"6551","url"=>"http://themeforest.net/category/site-templates"}, ... ]
111
+ ```
112
+
52
113
  ## Testing
53
114
 
54
115
  RSpec is the testing tool of choice and you can kick off the test suite by
@@ -92,6 +153,9 @@ It's super important you use real credentials when re-generating the cassettes
92
153
  to ensure it is an accurate representation of the interactions. (Don't worry, we
93
154
  don't commit your details to the cassettes they are filtered out by VCR!)
94
155
 
156
+ Note: Do not use the value of `ENVATO_TEST_API_USERNAME` in any of your tests
157
+ where it is passed into the URL. This will cause VCR not to create the cassette
158
+ due to the `ENVATO_TEST_API_USERNAME` being replaced during sanitisation.
95
159
  ## Releasing a new version
96
160
 
97
161
  Everything you need to build a new release can be done by running:
@@ -1,6 +1,7 @@
1
1
  require 'envato/connection'
2
2
  require 'envato/configurable'
3
3
  require 'envato/client/stats'
4
+ require 'envato/client/user'
4
5
 
5
6
  module Envato
6
7
  class Client
@@ -8,6 +9,7 @@ module Envato
8
9
  include Envato::Connection
9
10
  include Envato::Configurable
10
11
  include Envato::Client::Stats
12
+ include Envato::Client::User
11
13
 
12
14
  def initialize(options = {})
13
15
  Envato::Configurable.keys.each do |key|
@@ -29,6 +31,17 @@ module Envato
29
31
  inspected
30
32
  end
31
33
 
34
+ # Public: Conceal a sensitive string.
35
+ #
36
+ # This conceals everything in a string except for the first and last 4
37
+ # characters. Useful to hide sensitive data without removing it completely.
38
+ #
39
+ # Examples
40
+ #
41
+ # conceal('secretstring')
42
+ # # => 'secr****ring'
43
+ #
44
+ # Returns a String.
32
45
  def conceal(string)
33
46
  if string.length < 8
34
47
  '****'
@@ -38,5 +51,15 @@ module Envato
38
51
  "#{front}****#{back}"
39
52
  end
40
53
  end
54
+
55
+ private
56
+
57
+ def marketplace_names
58
+ %w(graphicriver themeforest activeden codecanyon videohive audiojungle photodune 3docean)
59
+ end
60
+
61
+ def marketplace_domains
62
+ marketplace_names.map { |domain| "#{domain}.net" }
63
+ end
41
64
  end
42
65
  end
@@ -2,14 +2,21 @@ module Envato
2
2
  class Client
3
3
  module Stats
4
4
  def total_users
5
- response = get 'market/total-users.json'
5
+ response = get 'v1/market/total-users.json'
6
6
  response['total-users']['total_users'].to_i
7
7
  end
8
8
 
9
9
  def total_items
10
- response = get 'market/total-items.json'
10
+ response = get 'v1/market/total-items.json'
11
11
  response['total-items']['total_items'].to_i
12
12
  end
13
+
14
+ def category_information_by_site(sitename)
15
+ raise Envato::InvalidSiteName unless marketplace_names.include? sitename
16
+
17
+ response = get "v1/market/number-of-files:#{sitename}.json"
18
+ response['number-of-files']
19
+ end
13
20
  end
14
21
  end
15
22
  end
@@ -0,0 +1,42 @@
1
+ module Envato
2
+ class Client
3
+ module User
4
+ def account_details
5
+ response = get 'v1/market/private/user/account.json'
6
+ response['account']
7
+ end
8
+
9
+ def username
10
+ response = get 'v1/market/private/user/username.json'
11
+ response['username']
12
+ end
13
+
14
+ def email_address
15
+ response = get 'v1/market/private/user/email.json'
16
+ response['email']
17
+ end
18
+
19
+ def user_information(username)
20
+ response = get "v1/market/user:#{username}.json"
21
+ response['user']
22
+ end
23
+
24
+ def badges_for_user(username)
25
+ response = get "v1/market/user-badges:#{username}.json"
26
+ response['user-badges']
27
+ end
28
+
29
+ def user_items_by_site(username)
30
+ response = get "v1/market/user-items-by-site:#{username}.json"
31
+ response['user-items-by-site']
32
+ end
33
+
34
+ def new_items_for_user(username, sitename)
35
+ raise Envato::InvalidSiteName unless marketplace_names.include? sitename
36
+
37
+ response = get "v1/market/new-files-from-user:#{username},#{sitename}.json"
38
+ response['new-files-from-user']
39
+ end
40
+ end
41
+ end
42
+ end
@@ -15,10 +15,6 @@ module Envato
15
15
  'https://api.envato.com'
16
16
  end
17
17
 
18
- def api_version
19
- 'v1'
20
- end
21
-
22
18
  private
23
19
 
24
20
  def request(method, url, options = {})
@@ -31,7 +27,7 @@ module Envato
31
27
 
32
28
  case method
33
29
  when :get
34
- response = request.get "#{api_version}/#{url}"
30
+ response = request.get(url)
35
31
  end
36
32
 
37
33
  case response.status.to_i
@@ -9,4 +9,8 @@ module Envato
9
9
  class NotFoundError < Error; end
10
10
  class ClientError < Error; end
11
11
  class ServerError < Error; end
12
+
13
+ # Validation of Envato marketplaces.
14
+ class InvalidSiteName < Error; end
15
+ class InvalidSiteDomain < Error; end
12
16
  end
@@ -1,6 +1,6 @@
1
1
  module Envato
2
2
  MAJOR = 0
3
- MINOR = 0
4
- PATCH = 5
3
+ MINOR = 1
4
+ PATCH = 0
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.5
4
+ version: 0.1.0
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-16 00:00:00.000000000 Z
11
+ date: 2015-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,6 +145,7 @@ files:
145
145
  - lib/envato.rb
146
146
  - lib/envato/client.rb
147
147
  - lib/envato/client/stats.rb
148
+ - lib/envato/client/user.rb
148
149
  - lib/envato/configurable.rb
149
150
  - lib/envato/connection.rb
150
151
  - lib/envato/errors.rb
@@ -174,3 +175,4 @@ signing_key:
174
175
  specification_version: 4
175
176
  summary: SDK for interacting with the Envato API.
176
177
  test_files: []
178
+ has_rdoc: