envato-sdk 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +51 -0
- data/lib/envato/client.rb +2 -0
- data/lib/envato/client/catalog.rb +47 -0
- data/lib/envato/client/user.rb +5 -0
- data/lib/envato/connection.rb +8 -3
- data/lib/envato/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eba7d159266289022ad43fd312e12054c515b072
|
|
4
|
+
data.tar.gz: f49b48c5cbbbd4b59b7e73cc124780546535ed2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b996f5d9ecf3e928b0f0da231f3b7efcd3ac971c42a0549863ac0925bb1510e8b9cd780bbe69f7ef57ee7553a43b405dcdb00291fcfec39f9191ff07bb64e1ae
|
|
7
|
+
data.tar.gz: e0731686315465fb4bed7a1837575fb5ca3cbc18251c4001eda983c546efc770dc12eb18ca3489d41c083b163c70b093494bd75caa7cc8d05da3865851a8004c
|
data/README.md
CHANGED
|
@@ -36,6 +36,57 @@ that you have already created a client called `client` as seen in the above
|
|
|
36
36
|
example. `...` represents multiple of the previous item repeated such as a hash
|
|
37
37
|
or array item.
|
|
38
38
|
|
|
39
|
+
#### Catalog
|
|
40
|
+
|
|
41
|
+
- [`get_public_collection`](https://build.envato.com/api/#market_0_Catalog_Collection)
|
|
42
|
+
|
|
43
|
+
```rb
|
|
44
|
+
client.get_public_collection(5507368)
|
|
45
|
+
# => {"id"=>5507368, "name"=>"Test public collection", "description"=>"This is an example public collection", "private"=>false, "item_count"=>1, "image"=>"default-collection.png"}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- [`get_item`](https://build.envato.com/api/#market_0_Catalog_Item)
|
|
49
|
+
|
|
50
|
+
```rb
|
|
51
|
+
client.get_item(14157442)
|
|
52
|
+
# => {"id"=>14157442, "name"=>"Beautiful Watercolor - Hand Painted Creative WordPress", "description"=>"<p><img src=\"http://dtbaker.net/wp-content/uploads/sites ...
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- [`popular_items_by_site`](https://build.envato.com/api/#market_Popular)
|
|
56
|
+
|
|
57
|
+
```rb
|
|
58
|
+
client.popular_items_by_site('themeforest')
|
|
59
|
+
# => {"items_last_week"=>[{"id"=>"2833226", "item"=>"Avada | Responsive Multi-Purpose Theme", "url"=>"http://themeforest.net/item/avada-responsive-multipurpose-theme/2833226", "user"=>"ThemeFusion", "thumbnail"=>"https://0.s3.envato.com/files/169508862/Thumbnail.jpg", "sales"=>"1939", "rating"=>"5.0", "rating_decimal"=>"4.78", "cost"=>"59.00", "uploaded_on"=>"Thu Aug 16 01:28:46 +1000 2012", "last_update"=>"Thu Jan 28 12:13:49 +1100 2016", "tags"=>"blog, business, clean, corporate, creative, ecommerce, modern, multipurpose, one page, photography, portfolio, responsive, retina, woocommerce, wordpress", "category"=>"wordpress/corporate", "live_preview_url"=>"https://0.s3.envato.com/files/169508866/screenshots/00_preview.__large_preview.jpg"}, {"id"=>"5871901", "item"=>"X | The Theme", ...
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- [`categories_by_site`](https://build.envato.com/api/#market_Categories)
|
|
63
|
+
|
|
64
|
+
```rb
|
|
65
|
+
client.categories_by_site('themeforest')
|
|
66
|
+
# => [{"name"=>"Site Templates", "path"=>"site-templates"}, {"name"=>"Creative", "path"=>"site-templates/creative"}, {"name"=>"Portfolio", "path"=>"site-templates/creative/portfolio"}, {"name"=>"Photography", "path"=>"site-templates/creative/photography"}, {"name"=>"Art", "path"=>"site-templates/creative/art"}, {"name"=>"Experimental", "path"=>"site-templates/creative/experimental"} ...]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- [`prices_for_item`](https://build.envato.com/api/#market_ItemPrices)
|
|
70
|
+
|
|
71
|
+
```rb
|
|
72
|
+
client.prices_for_item(13582227)
|
|
73
|
+
# => [{"licence"=>"Regular License", "price"=>"24.00"}, {"licence"=>"Extended License", "price"=>"1200.00"}]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- [`featured_by_site`](https://build.envato.com/api/#market_Features)
|
|
77
|
+
|
|
78
|
+
```rb
|
|
79
|
+
client.featured_by_site('themeforest')
|
|
80
|
+
# => {"featured_file"=>{"id"=>"14631264", "item"=>"Luxury - Responsive Virtuemart Theme", "url"=>"http://themeforest.net/item/luxury-responsive-virtuemart-theme/14631264", "user"=>"dasinfomedia", "thumbnail"=>"https://0.s3.envato.com/files/169212120/luxury_thumb_jml.png", "sales"=>"27", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"48.00", "uploaded_on"=>"Wed Feb 03 04:32:39 +1100 2016", "last_update"=>"Wed Mar 23 01:40:20 +1100 2016", "tags"=>"clean, clear shop, clothing, creative design, fashion, home furniture, joomla 3 theme, lifestyle, modern, online shop, professional joomla template", "category"=>"cms-themes/joomla/retail/fashion", "live_preview_url"=>"https://0.s3.envato.com/files/169212284/01_preview.__large_preview.png"}, "featured_author"=>{"id"=>"2016597", "user"=>"DigitalAtelier", "url"=>"http://themeforest.net/user/digitalatelier", "thumbnail"=>"https://0.s3.envato.com/files/50767715/logo.png"}, "free_file"=>{"id"=>"11403244", "item"=>"Melica – Responsive WordPress Blog Theme", "url"=>"http://themeforest.net/item/melica-responsive-wordpress-blog-theme/11403244", "user"=>"wphunters", "thumbnail"=>"https://0.s3.envato.com/files/174945675/thumbnail.png", "sales"=>"52", "rating"=>"5.0", "rating_decimal"=>"5.00", "cost"=>"44.00", "uploaded_on"=>"Fri May 22 05:00:32 +1000 2015", "last_update"=>"Wed Mar 02 00:53:28 +1100 2016", "tags"=>"blog, blogger, clean, creative, fashion, food, instagram, minimal, modern, music, personal,slider, travel, video", "category"=>"wordpress/blog-magazine/personal", "live_preview_url"=>"https://0.s3.envato.com/files/174945678/preview_wp.__large_preview.jpg"}}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- [`random_new_items_by_site`](https://build.envato.com/api/#market_RandomNewFiles)
|
|
84
|
+
|
|
85
|
+
```rb
|
|
86
|
+
client.random_new_items_by_site('themeforest')
|
|
87
|
+
# => [{"id"=>"15345030", "item"=>"Legal justice - HTML Template", "url"=>"http://themeforest.net/item/legal-justice-html-template/15345030", "user"=>"Xstyler", "thumbnail"=>"https://0.s3.envato.com/files/176988930/Thumbnail.png", "sales"=>"0", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"15.00"}, {"id"=>"15346859", "item"=>"Gear — Automotive Business/Auto Parts Store PSD Template", "url"=>"http://themeforest.net/item/gear-automotive-businessauto-parts-store-psd-template/15346859", "user"=>"torbara", "thumbnail"=>"https://0.s3.envato.com/files/177009058/Gear_Icon.png", "sales"=>"0", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"12.00"}, {"id"=>"15343695", "item"=>"Noren - Multi Store Responsive HTML Template","url"=>"http://themeforest.net/item/noren-multi-store-responsive-html-template/15343695", "user"=>"EngoTheme", "thumbnail"=>"https://0.s3.envato.com/files/178795450/80x80.jpg", "sales"=>"0", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"17.00"}, {"id"=>"14770935", "item"=>"Outlaw - Stylish WooCommerce WordPress Theme", "url"=>"http://themeforest.net/item/outlaw-stylish-woocommerce-wordpress-theme/14770935", "user"=>"elusivethemes", "thumbnail"=>"https://0.s3.envato.com/files/178441822/thumb.jpg", "sales"=>"0", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"59.00"}, {"id"=>"15101532", "item"=>"Ri Quartz - Responsive Multipurpose WooCommerce Theme", "url"=>"http://themeforest.net/item/ri-quartz-responsive-multipurpose-woocommerce-theme/15101532", "user"=>"CleverSoft", "thumbnail"=>"https://0.s3.envato.com/files/174287786/quartz.jpg", "sales"=>"1", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"59.00"}, {"id"=>"15332367", "item"=>"Highstand - Responsive MultiPurpose HTML5 Template ", "url"=>"http://themeforest.net/item/highstand-responsive-multipurpose-html5-template-/15332367", "user"=>"gsrthemes9", "thumbnail"=>"https://0.s3.envato.com/files/178795406/thumb.jpg", "sales"=>"1", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"17.00"}, {"id"=>"15156133", "item"=>"James - Responsive WooCommerce Shoes Theme", "url"=>"http://themeforest.net/item/james-responsive-woocommerce-shoes-theme/15156133", "user"=>"roadthemes", "thumbnail"=>"https://0.s3.envato.com/files/178879482/thumbnail.png", "sales"=>"0", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"59.00"}, {"id"=>"15319096", "item"=>"Mozar - Fashion Clothing Bootstrap Template", "url"=>"http://themeforest.net/item/mozar-fashion-clothing-bootstrap-template/15319096", "user"=>"BootExperts", "thumbnail"=>"https://0.s3.envato.com/files/176721976/thumbnail.png", "sales"=>"0", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"17.00"}, {"id"=>"14752612", "item"=>"Hash - Responsive WordPress Magazine Theme", "url"=>"http://themeforest.net/item/hash-responsive-wordpress-magazine-theme/14752612", "user"=>"PremiumLayers", "thumbnail"=>"https://0.s3.envato.com/files/178438623/80x80.jpg", "sales"=>"0", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"49.00"}, {"id"=>"15079135", "item"=>"BlueMed - Health and Medical WordPress Theme", "url"=>"http://themeforest.net/item/bluemed-health-and-medical-wordpress-theme/15079135", "user"=>"happy_robot", "thumbnail"=>"https://0.s3.envato.com/files/178384359/icon.png", "sales"=>"1", "rating"=>"0.0", "rating_decimal"=>"0.00", "cost"=>"49.00"}]
|
|
88
|
+
```
|
|
89
|
+
|
|
39
90
|
#### User
|
|
40
91
|
|
|
41
92
|
- [`account_details`](https://build.envato.com/api/#market_Account)
|
data/lib/envato/client.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'envato/connection'
|
|
|
2
2
|
require 'envato/configurable'
|
|
3
3
|
require 'envato/client/stats'
|
|
4
4
|
require 'envato/client/user'
|
|
5
|
+
require 'envato/client/catalog'
|
|
5
6
|
|
|
6
7
|
module Envato
|
|
7
8
|
class Client
|
|
@@ -10,6 +11,7 @@ module Envato
|
|
|
10
11
|
include Envato::Configurable
|
|
11
12
|
include Envato::Client::Stats
|
|
12
13
|
include Envato::Client::User
|
|
14
|
+
include Envato::Client::Catalog
|
|
13
15
|
|
|
14
16
|
def initialize(options = {})
|
|
15
17
|
Envato::Configurable.keys.each do |key|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Envato
|
|
2
|
+
class Client
|
|
3
|
+
module Catalog
|
|
4
|
+
def get_public_collection(collection_id)
|
|
5
|
+
response = get "v3/market/catalog/collection?id=#{collection_id}"
|
|
6
|
+
response['collection']
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def get_item(item_id)
|
|
10
|
+
get "v3/market/catalog/item?id=#{item_id}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def popular_items_by_site(sitename)
|
|
14
|
+
raise Envato::InvalidSiteName unless marketplace_names.include? sitename
|
|
15
|
+
|
|
16
|
+
response = get "v1/market/popular:#{sitename}.json"
|
|
17
|
+
response['popular']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def categories_by_site(sitename)
|
|
21
|
+
raise Envato::InvalidSiteName unless marketplace_names.include? sitename
|
|
22
|
+
|
|
23
|
+
response = get "v1/market/categories:#{sitename}.json"
|
|
24
|
+
response['categories']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def prices_for_item(item_id)
|
|
28
|
+
response = get "v1/market/item-prices:#{item_id}.json"
|
|
29
|
+
response['item-prices']
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def featured_by_site(sitename)
|
|
33
|
+
raise Envato::InvalidSiteName unless marketplace_names.include? sitename
|
|
34
|
+
|
|
35
|
+
response = get "v1/market/features:#{sitename}.json"
|
|
36
|
+
response['features']
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def random_new_items_by_site(sitename)
|
|
40
|
+
raise Envato::InvalidSiteName unless marketplace_names.include? sitename
|
|
41
|
+
|
|
42
|
+
response = get "v1/market/random-new-files:#{sitename}.json"
|
|
43
|
+
response['random-new-files']
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/envato/client/user.rb
CHANGED
|
@@ -37,6 +37,11 @@ module Envato
|
|
|
37
37
|
response = get "v1/market/new-files-from-user:#{username},#{sitename}.json"
|
|
38
38
|
response['new-files-from-user']
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
def user_collections
|
|
42
|
+
response = get 'v3/market/user/collections.json'
|
|
43
|
+
response['collections']
|
|
44
|
+
end
|
|
40
45
|
end
|
|
41
46
|
end
|
|
42
47
|
end
|
data/lib/envato/connection.rb
CHANGED
|
@@ -32,7 +32,7 @@ module Envato
|
|
|
32
32
|
|
|
33
33
|
case response.status.to_i
|
|
34
34
|
when 403 then raise Envato::ForbiddenError, extract_forbidden_message(response)
|
|
35
|
-
when 404 then raise Envato::NotFoundError
|
|
35
|
+
when 404 then raise Envato::NotFoundError, extract_not_found_message(response)
|
|
36
36
|
when 405..499 then raise Envato::ClientError
|
|
37
37
|
when 500..599 then raise Envato::ServerError, extract_server_error_message(response)
|
|
38
38
|
end
|
|
@@ -46,12 +46,17 @@ module Envato
|
|
|
46
46
|
|
|
47
47
|
def extract_forbidden_message(response)
|
|
48
48
|
body = JSON.parse(response.body)
|
|
49
|
-
body['error_description']
|
|
49
|
+
body['error_description'] if body['error_description']
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def extract_not_found_message(response)
|
|
53
|
+
body = JSON.parse(response.body)
|
|
54
|
+
body['description'] if body['description']
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
def extract_server_error_message(response)
|
|
53
58
|
body = JSON.parse(response.body)
|
|
54
|
-
body['message']
|
|
59
|
+
body['message'] if body['message']
|
|
55
60
|
end
|
|
56
61
|
end
|
|
57
62
|
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.
|
|
4
|
+
version: 0.2.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:
|
|
11
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -144,6 +144,7 @@ files:
|
|
|
144
144
|
- lib/envato-sdk.rb
|
|
145
145
|
- lib/envato.rb
|
|
146
146
|
- lib/envato/client.rb
|
|
147
|
+
- lib/envato/client/catalog.rb
|
|
147
148
|
- lib/envato/client/stats.rb
|
|
148
149
|
- lib/envato/client/user.rb
|
|
149
150
|
- lib/envato/configurable.rb
|
|
@@ -170,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
170
171
|
version: '0'
|
|
171
172
|
requirements: []
|
|
172
173
|
rubyforge_project:
|
|
173
|
-
rubygems_version: 2.
|
|
174
|
+
rubygems_version: 2.5.1
|
|
174
175
|
signing_key:
|
|
175
176
|
specification_version: 4
|
|
176
177
|
summary: SDK for interacting with the Envato API.
|