envato 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -0
  3. data/.github/workflows/ci.yml +51 -0
  4. data/.gitignore +1 -0
  5. data/README.md +6 -147
  6. data/envato.gemspec +7 -7
  7. data/lib/envato/version.rb +1 -1
  8. data/lib/envato.rb +2 -5
  9. metadata +38 -79
  10. data/Gemfile.lock +0 -84
  11. data/spec/bookmarks_spec.rb +0 -15
  12. data/spec/envato_spec.rb +0 -26
  13. data/spec/item_spec.rb +0 -90
  14. data/spec/market_spec.rb +0 -100
  15. data/spec/markets_spec.rb +0 -14
  16. data/spec/search_spec.rb +0 -41
  17. data/spec/spec_helper.rb +0 -51
  18. data/spec/user_spec.rb +0 -118
  19. data/spec/users_spec.rb +0 -15
  20. data/spec/vcr/bookmarks_list.yml +0 -87
  21. data/spec/vcr/item_info.yml +0 -88
  22. data/spec/vcr/item_list_purchases.yml +0 -87
  23. data/spec/vcr/item_prices.yml +0 -86
  24. data/spec/vcr/item_purchases.yml +0 -87
  25. data/spec/vcr/item_version.yml +0 -87
  26. data/spec/vcr/market_categories_graphicriver.yml +0 -147
  27. data/spec/vcr/market_categories_themeforest.yml +0 -201
  28. data/spec/vcr/market_features_graphicriver.yml +0 -97
  29. data/spec/vcr/market_features_themeforest.yml +0 -93
  30. data/spec/vcr/market_new_files.yml +0 -86
  31. data/spec/vcr/market_new_files_graphicriver_graphics.yml +0 -115
  32. data/spec/vcr/market_popular_items_themeforest.yml +0 -86
  33. data/spec/vcr/market_total_items.yml +0 -85
  34. data/spec/vcr/search_comments.yml +0 -88
  35. data/spec/vcr/search_item.yml +0 -88
  36. data/spec/vcr/search_more_like_this.yml +0 -88
  37. data/spec/vcr/user_account.yml +0 -86
  38. data/spec/vcr/user_badges.yml +0 -98
  39. data/spec/vcr/user_badges_not_exists.yml +0 -83
  40. data/spec/vcr/user_collection.yml +0 -88
  41. data/spec/vcr/user_collections.yml +0 -90
  42. data/spec/vcr/user_email.yml +0 -85
  43. data/spec/vcr/user_items.yml +0 -86
  44. data/spec/vcr/user_name.yml +0 -85
  45. data/spec/vcr/user_statement.yml +0 -111
  46. data/spec/vcr/users_total.yml +0 -85
data/spec/item_spec.rb DELETED
@@ -1,90 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
- require "envato"
5
-
6
- RSpec.describe "#item.info" do
7
- context "with id param" do
8
- subject(:resp) do
9
- VCR.use_cassette("item_info") do
10
- @envato.item.info(id: "5556590")
11
- end
12
- end
13
-
14
- it { expect(resp).to be_an(Envato::Item) }
15
- it { expect(resp.tags).to be_an(Array) }
16
- it { expect(resp.attributes).to be_an(Array) }
17
- it { expect(resp.previews).to be_an(OpenStruct) }
18
- it { expect(resp.site).to eq("themeforest.net") }
19
- end
20
-
21
- context "without id param" do
22
- subject(:resp) do
23
- VCR.use_cassette("item_info") do
24
- @envato.item.info
25
- end
26
- end
27
-
28
- it { expect { resp }.to raise_error(ArgumentError) }
29
- end
30
- end
31
-
32
- RSpec.describe "#item.version" do
33
- context "with id param" do
34
- subject(:resp) do
35
- VCR.use_cassette("item_version") do
36
- @envato.item.version(id: "5556590")
37
- end
38
- end
39
-
40
- it { expect(resp).to be_instance_of(Envato::ItemVersion) }
41
- end
42
-
43
- context "without id param" do
44
- subject(:resp) do
45
- VCR.use_cassette("item_version") do
46
- @envato.item.version
47
- end
48
- end
49
-
50
- it { expect { resp }.to raise_error(ArgumentError) }
51
- end
52
- end
53
-
54
- RSpec.describe "#item.prices" do
55
- context "with id param" do
56
- subject(:resp) do
57
- VCR.use_cassette("item_prices") do
58
- @envato.item.prices(item_id: "5556590")
59
- end
60
- end
61
-
62
- it { expect(resp).to be_instance_of(Envato::Collection) }
63
- it { expect(resp.data.first).to be_instance_of(Envato::ItemPrice) }
64
- end
65
-
66
- context "without id param" do
67
- it { expect { @envato.item.prices }.to raise_error(ArgumentError, /missing keyword/) }
68
- end
69
- end
70
-
71
- RSpec.describe "#item.purchases" do
72
- subject(:resp) do
73
- VCR.use_cassette("item_purchases") do
74
- @envato.item.purchases
75
- end
76
- end
77
-
78
- it { expect(resp).to be_instance_of(Envato::Collection) }
79
- end
80
-
81
- RSpec.describe "#item.list_purchases" do
82
- subject(:resp) do
83
- VCR.use_cassette("item_list_purchases") do
84
- @envato.item.list_purchases
85
- end
86
- end
87
-
88
- it { expect(resp).to be_instance_of(Envato::Collection) }
89
- it { expect(resp.data.count).to be_instance_of(Integer) }
90
- end
data/spec/market_spec.rb DELETED
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
- require "envato"
5
-
6
- RSpec.describe "#market.categories" do
7
- context "when site is themeforest" do
8
- subject(:resp) do
9
- VCR.use_cassette("market_categories_themeforest") do
10
- @envato.market.categories site: "themeforest"
11
- end
12
- end
13
-
14
- it { expect(resp).to be_instance_of(Envato::Collection) }
15
- it { expect(resp.data.first).to be_instance_of(Envato::Category) }
16
- it { expect(resp.data.first.name).to eq "Site Templates" }
17
- it { expect(resp.data.first.path).to eq "site-templates" }
18
- end
19
-
20
- context "when site is graphicriver" do
21
- subject(:resp) do
22
- VCR.use_cassette("market_categories_graphicriver") do
23
- @envato.market.categories_graphicriver
24
- end
25
- end
26
-
27
- it { expect(resp).to be_instance_of(Envato::Collection) }
28
- it { expect(resp.data.first).to be_instance_of(Envato::Category) }
29
- it { expect(resp.data.first.name).to eq "Graphics" }
30
- it { expect(resp.data.first.path).to eq "graphics" }
31
- end
32
- end
33
-
34
- RSpec.describe "#market.features" do
35
- context "when site is themeforest" do
36
- subject(:resp) do
37
- VCR.use_cassette("market_features_themeforest") do
38
- @envato.market.features site: "themeforest"
39
- end
40
- end
41
-
42
- # TODO: Object to Features
43
- it { expect(resp).to be_an(Envato::Object) }
44
- it { expect(resp.features.free_file).to be_an OpenStruct }
45
- it { expect(resp.features.featured_file).to be_an OpenStruct }
46
- it { expect(resp.features.featured_author).to be_an OpenStruct }
47
- end
48
-
49
- context "when site is graphicriver" do
50
- subject(:resp) do
51
- VCR.use_cassette("market_features_graphicriver") do
52
- @envato.market.features_graphicriver
53
- end
54
- end
55
-
56
- it { expect(resp).to be_instance_of(Envato::Object) }
57
- it { expect(resp.features.free_file).to be_an OpenStruct }
58
- it { expect(resp.features.featured_file).to be_an OpenStruct }
59
- it { expect(resp.features.featured_author).to be_an OpenStruct }
60
- end
61
- end
62
-
63
- RSpec.describe "#market.new_files" do
64
- context "when site is themeforest" do
65
- subject(:resp) do
66
- VCR.use_cassette("market_new_files") do
67
- @envato.market.new_files(site: "themeforest", category: "site-templates")
68
- end
69
- end
70
-
71
- it { expect(resp).to be_instance_of(Envato::Collection) }
72
- it { expect(resp.data.first).to be_an OpenStruct }
73
- end
74
-
75
- context "when site is graphicriver" do
76
- context "ant category is graphics" do
77
- subject(:resp) do
78
- VCR.use_cassette("market_new_files_graphicriver_graphics") do
79
- @envato.market.new_files_graphicriver category: "graphics"
80
- end
81
- end
82
-
83
- it { expect(resp).to be_instance_of(Envato::Collection) }
84
- it { expect(resp.data.first).to be_an OpenStruct }
85
- end
86
- end
87
- end
88
-
89
- RSpec.describe "#market.popular_items" do
90
- subject(:resp) do
91
- VCR.use_cassette("market_popular_items_themeforest") do
92
- @envato.market.popular_items site: "themeforest"
93
- end
94
- end
95
-
96
- it { expect(resp).to be_instance_of(Envato::Object) }
97
- it { expect(resp.popular).to be_instance_of(OpenStruct) }
98
- it { expect(resp.popular.items_last_week).to be_instance_of(Array) }
99
- it { expect(resp.popular.items_last_week.first.id).not_to be(nil) }
100
- end
data/spec/markets_spec.rb DELETED
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
- require "envato"
5
-
6
- RSpec.describe "#markets.total_items" do
7
- subject(:resp) do
8
- VCR.use_cassette("market_total_items") do
9
- @envato.markets.total_items
10
- end
11
- end
12
-
13
- it { expect(resp["total-items"].total_items).to eq("12743594") }
14
- end
data/spec/search_spec.rb DELETED
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
- require "envato"
5
-
6
- RSpec.describe "#search.more_like_this" do
7
- context "with item_id param" do
8
- subject(:resp) do
9
- VCR.use_cassette("search_more_like_this") do
10
- @envato.search.more_like_this(item_id: "5556590")
11
- end
12
- end
13
-
14
- it { expect(resp).to be_instance_of(Envato::Collection) }
15
- it { expect(resp.data.first).to be_instance_of(Envato::Item) }
16
- end
17
- end
18
-
19
- RSpec.describe "#search.comments" do
20
- context "with item_id param" do
21
- subject(:resp) do
22
- VCR.use_cassette("search_comments") do
23
- @envato.search.comments(item_id: "5556590")
24
- end
25
- end
26
-
27
- it { expect(resp).to be_instance_of(Envato::Collection) }
28
- it { expect(resp.data.first).to be_instance_of(Envato::Comment) }
29
- end
30
- end
31
-
32
- RSpec.describe "#search.item" do
33
- subject(:resp) do
34
- VCR.use_cassette("search_item") do
35
- @envato.search.item
36
- end
37
- end
38
-
39
- it { expect(resp).to be_instance_of(Envato::Collection) }
40
- it { expect(resp.data.first).to be_instance_of(Envato::Item) }
41
- end
data/spec/spec_helper.rb DELETED
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/setup"
4
- require "simplecov"
5
- require "envato"
6
- require "webmock/rspec"
7
- require "vcr"
8
-
9
- SimpleCov.start do
10
- add_filter "spec/"
11
- add_group "Lib", "lib"
12
- minimum_coverage 80.0
13
- end
14
-
15
- ACCESS_TOKEN = ENV["ENVATO_ACCESS_TOKEN"] || "SECRET_TOKEN"
16
-
17
- RSpec.configure do |config|
18
- config.before(:each) do
19
- @envato = Envato::Client.new(token: ACCESS_TOKEN)
20
- end
21
-
22
- config.example_status_persistence_file_path = ".rspec_status"
23
- config.disable_monkey_patching!
24
-
25
- config.expect_with :rspec do |c|
26
- c.syntax = :expect
27
- c.include_chain_clauses_in_custom_matcher_descriptions = true
28
- end
29
-
30
- config.mock_with :rspec do |mocks|
31
- mocks.verify_partial_doubles = true
32
- end
33
- config.shared_context_metadata_behavior = :apply_to_host_groups
34
- end
35
-
36
- VCR.configure do |c|
37
- c.ignore_localhost = true
38
- c.cassette_library_dir = "spec/vcr"
39
- c.hook_into :webmock
40
-
41
- c.default_cassette_options = {
42
- decode_compressed_response: true,
43
- allow_unused_http_interactions: false
44
- }
45
-
46
- c.filter_sensitive_data("TOKEN") do |i|
47
- i.request["headers"]["Authorization"].first
48
- end
49
-
50
- c.configure_rspec_metadata!
51
- end
data/spec/user_spec.rb DELETED
@@ -1,118 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
- require "envato"
5
-
6
- RSpec.describe "#user.name" do
7
- subject(:resp) do
8
- VCR.use_cassette("user_name") do
9
- @envato.user.name
10
- end
11
- end
12
-
13
- it { expect(resp.username).to eq("collis") }
14
- end
15
-
16
- RSpec.describe "#user.email" do
17
- subject(:resp) do
18
- VCR.use_cassette("user_email") do
19
- @envato.user.email
20
- end
21
- end
22
-
23
- it { expect(resp.email).to eq("email@example.com") }
24
- end
25
-
26
- RSpec.describe "#user.badges" do
27
- context "when user exists" do
28
- subject(:resp) do
29
- VCR.use_cassette("user_badges") do
30
- @envato.user.badges username: "collis"
31
- end
32
- end
33
-
34
- it { expect(resp).to be_instance_of Envato::Collection }
35
- it { expect(resp.data.first).to be_instance_of Envato::UserBadge }
36
- it { expect(resp.data.first.name).to be_instance_of String }
37
- it { expect(resp.data.first.label).to be_instance_of String }
38
- it { expect(resp.data.first.image).to be_instance_of String }
39
- end
40
-
41
- context "when the user does not exists" do
42
- subject(:resp) do
43
- VCR.use_cassette("user_badges_not_exists") do
44
- @envato.user.badges username: "collis123"
45
- end
46
- end
47
-
48
- it { expect { resp }.to raise_error Envato::Error, /could not find the user/ }
49
- end
50
- end
51
-
52
- RSpec.describe "#user.account" do
53
- subject(:resp) do
54
- VCR.use_cassette("user_account") do
55
- @envato.user.account
56
- end
57
- end
58
-
59
- it { expect(resp).to be_instance_of(Envato::UserAccount) }
60
- end
61
-
62
- RSpec.describe "#user.collections" do
63
- subject(:resp) do
64
- VCR.use_cassette("user_collections") do
65
- @envato.user.collections
66
- end
67
- end
68
-
69
- it { expect(resp).to be_instance_of(Envato::Collection) }
70
- it { expect(resp.data.first).to be_instance_of(Envato::UserCollection) }
71
- end
72
-
73
- RSpec.describe "#user.collection" do
74
- context "with id param" do
75
- subject(:resp) do
76
- VCR.use_cassette("user_collection") do
77
- @envato.user.collection(id: "4551957")
78
- end
79
- end
80
-
81
- it { expect(resp).to be_instance_of(Envato::Collection) }
82
- it { expect(resp.items).to be_instance_of(Array) }
83
- end
84
-
85
- context "without id param" do
86
- subject(:resp) do
87
- VCR.use_cassette("user_collection") do
88
- @envato.user.collection
89
- end
90
- end
91
-
92
- it { expect { resp }.to raise_error(ArgumentError) }
93
- end
94
- end
95
-
96
- RSpec.describe "#user.statement" do
97
- subject(:resp) do
98
- VCR.use_cassette("user_statement") do
99
- @envato.user.statement
100
- end
101
- end
102
-
103
- it { expect(resp).to be_instance_of(Envato::UserStatement) }
104
- it { expect(resp.count).to be_an(Integer) }
105
- it { expect(resp.results).to be_instance_of(Array) }
106
- it { expect(resp.results.first).to be_instance_of(OpenStruct) }
107
- end
108
-
109
- RSpec.describe "#user.items" do
110
- subject(:resp) do
111
- VCR.use_cassette("user_items") do
112
- @envato.user.items username: "collis"
113
- end
114
- end
115
-
116
- it { expect(resp).to be_instance_of(Envato::Collection) }
117
- it { expect(resp.data.first).to be_an(Envato::Item) }
118
- end
data/spec/users_spec.rb DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
- require "envato"
5
-
6
- RSpec.describe "#users.total" do
7
- subject(:resp) do
8
- VCR.use_cassette("users_total") do
9
- @envato.users.total
10
- end
11
- end
12
-
13
- it { expect(resp).to be_instance_of(Envato::UsersTotal) }
14
- it { expect(resp["total-users"].total_users).to eq("16863730") }
15
- end
@@ -1,87 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.envato.com/v3/market/user/bookmarks
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v1.10.2
12
- Authorization:
13
- - TOKEN
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- Accept:
17
- - "*/*"
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Date:
24
- - Tue, 11 Oct 2022 21:21:03 GMT
25
- Content-Type:
26
- - application/json; charset=utf-8
27
- Content-Length:
28
- - '523'
29
- Connection:
30
- - keep-alive
31
- X-Amzn-Requestid:
32
- - 7d081f26-8e81-439b-85d8-f2d774071303
33
- Referrer-Policy:
34
- - origin-when-cross-origin
35
- X-Xss-Protection:
36
- - 1; mode=block
37
- X-Runtime:
38
- - '0.094356'
39
- Access-Control-Allow-Origin:
40
- - "*"
41
- Strict-Transport-Security:
42
- - max-age=31536000
43
- X-Frame-Options:
44
- - SAMEORIGIN
45
- X-Amzn-Remapped-Connection:
46
- - keep-alive
47
- X-Download-Options:
48
- - noopen
49
- X-Request-Id:
50
- - 758aa4a8988216bf-DME
51
- X-Amz-Apigw-Id:
52
- - Z2-p4HhDIAMFWLw=
53
- Vary:
54
- - Accept
55
- Cache-Control:
56
- - no-store
57
- X-Amzn-Remapped-Server:
58
- - nginx
59
- Expires:
60
- - '0'
61
- X-Content-Type-Options:
62
- - nosniff
63
- Etag:
64
- - W/"e2f6cca18db456fdf6aa1202b5f9ae90"
65
- Pragma:
66
- - no-cache
67
- X-Amzn-Remapped-Date:
68
- - Tue, 11 Oct 2022 21:21:03 GMT
69
- X-Cache:
70
- - Miss from cloudfront
71
- Via:
72
- - 1.1 c379418fd6100691807f32f274ebe9ce.cloudfront.net (CloudFront)
73
- X-Amz-Cf-Pop:
74
- - FRA2-C1
75
- X-Amz-Cf-Id:
76
- - NHBKVSMYNy90VqmmHdVBFNrzyH2tTyhBqOAGqSv32wmLQ3lLlev0-g==
77
- Cf-Cache-Status:
78
- - DYNAMIC
79
- Server:
80
- - cloudflare
81
- Cf-Ray:
82
- - 758aa4a8988216bf-DME
83
- body:
84
- encoding: ASCII-8BIT
85
- string: '{"bookmarks":[{"id":51165728,"item_id":20067217,"collection_id":6917126},{"id":55189448,"item_id":20262330,"collection_id":7201994},{"id":68229162,"item_id":2871437,"collection_id":4753344},{"id":68229159,"item_id":3114354,"collection_id":4753344},{"id":73242703,"item_id":3525764,"collection_id":4753344},{"id":36080084,"item_id":11890210,"collection_id":4753344},{"id":36080108,"item_id":15190981,"collection_id":4753344},{"id":36080030,"item_id":15380226,"collection_id":4753344},{"id":51165721,"item_id":20067217,"collection_id":4753344},{"id":68229101,"item_id":22848477,"collection_id":4753344},{"id":73024798,"item_id":24030418,"collection_id":4753344},{"id":73024801,"item_id":24291918,"collection_id":4753344},{"id":70315296,"item_id":24632692,"collection_id":4753344},{"id":73106581,"item_id":25542839,"collection_id":4753344},{"id":73106806,"item_id":26167207,"collection_id":4753344},{"id":73106781,"item_id":26292187,"collection_id":4753344},{"id":71818071,"item_id":26871435,"collection_id":4753344},{"id":70632683,"item_id":26988802,"collection_id":4753344},{"id":70632687,"item_id":27346574,"collection_id":4753344},{"id":73024809,"item_id":27412116,"collection_id":4753344},{"id":73024806,"item_id":27596563,"collection_id":4753344},{"id":73024805,"item_id":27873473,"collection_id":4753344},{"id":73024810,"item_id":28061946,"collection_id":4753344},{"id":73024800,"item_id":28451453,"collection_id":4753344},{"id":73024807,"item_id":28796118,"collection_id":4753344},{"id":73024811,"item_id":29362284,"collection_id":4753344},{"id":78406313,"item_id":32949822,"collection_id":4753344},{"id":78406311,"item_id":33272512,"collection_id":4753344},{"id":6552137,"item_id":387244,"collection_id":706951},{"id":4774202,"item_id":467167,"collection_id":706951},{"id":9103119,"item_id":2199794,"collection_id":706951},{"id":9127674,"item_id":3050124,"collection_id":706951},{"id":68229161,"item_id":3114354,"collection_id":706951},{"id":9140257,"item_id":3411959,"collection_id":706951},{"id":9103142,"item_id":4367571,"collection_id":706951},{"id":9178293,"item_id":4524003,"collection_id":706951},{"id":55186364,"item_id":21788834,"collection_id":7201768}]}'
86
- recorded_at: Tue, 11 Oct 2022 21:21:03 GMT
87
- recorded_with: VCR 6.1.0