gettyimages-api 2.0.0 → 3.0.1

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
- SHA1:
3
- metadata.gz: 6b5c91bd5871d4cb8761930aeb093fe47a0c5d85
4
- data.tar.gz: 644524093d4158f6f95c1dca4da520c5955e8dd6
2
+ SHA256:
3
+ metadata.gz: 997e7f50a48676a01163f288529a8e26129ff288e220593d4c33a240edad4ceb
4
+ data.tar.gz: a44a0e727ba765c23c4e44360088b27d9526283fd5b21dc230bb883a42542787
5
5
  SHA512:
6
- metadata.gz: c9f560e82439206b16671f81b5f76cfb158dea1217a1ab28282902053cb7288ce32adfd33f8dbefd54153301db0a715a183d55e3a26d1d529cf1f151f6535623
7
- data.tar.gz: 9afd14e656e430f98c747d2418fdc6f72e564f8475b987ae8c09d04e137b6b173ffc65eba024d6fc63e31c1e4560f256300b0c2a4b6c814430f856056db7062e
6
+ metadata.gz: c43ff3f1dbb02255792b2fc0dd6ef490a5de0a55975d249310cffb4d983efecef04654f962d14a171ae3d25dc29d9fb5152860a5513585c41d51a0ac0177bd19
7
+ data.tar.gz: 15bd7ce9133f5457429376fdbcf1db10127472224ff02ba9790dfb5f5f6c1c19a4ea2c8d1ed66657a5b1bcac4177910885b6de15698f755e26d4c7338fc09bab
@@ -0,0 +1,35 @@
1
+ name: Build
2
+
3
+ on:
4
+ push:
5
+ branches: [ master, actions ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: [ 2.5, 2.6, 2.7 ]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby-version }}
25
+
26
+ - name: 'Get Previous tag'
27
+ id: previoustag
28
+ uses: "WyriHaximus/github-action-get-previous-tag@v1"
29
+
30
+ - name: Set version
31
+ run: |
32
+ sed -i -e "s/0.0.0/${{ steps.previoustag.outputs.tag }}/" lib/GettyImagesApi/version.rb
33
+ cat lib/GettyImagesApi/version.rb
34
+
35
+ - run: make build
@@ -0,0 +1,40 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [released]
6
+
7
+ jobs:
8
+ test:
9
+
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ with:
15
+ fetch-depth: 0
16
+
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.5
20
+
21
+ - name: 'Get Previous tag'
22
+ id: previoustag
23
+ uses: "WyriHaximus/github-action-get-previous-tag@v1"
24
+
25
+ - name: Set version
26
+ run: |
27
+ sed -i -e "s/0.0.0/${{ steps.previoustag.outputs.tag }}/" lib/GettyImagesApi/version.rb
28
+ cat lib/GettyImagesApi/version.rb
29
+
30
+ - run: make build
31
+
32
+ - name: Publish to RubyGems
33
+ run: |
34
+ mkdir -p $HOME/.gem
35
+ touch $HOME/.gem/credentials
36
+ chmod 0600 $HOME/.gem/credentials
37
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
38
+ gem push gettyimages-api-${{ steps.previoustag.outputs.tag }}.gem
39
+ env:
40
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ *.gem
16
+ vendor
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  gem 'rake'
4
4
  gem 'json'
5
5
  gem 'test-unit'
6
- gem 'webmock'
6
+ gem 'webmock'
data/Makefile ADDED
@@ -0,0 +1,5 @@
1
+ build:
2
+ bundle config set --local path 'vendor/bundle'
3
+ bundle install --path vendor/bundle
4
+ bundle exec rake
5
+ gem build gettyimages-api.gemspec
data/README.md CHANGED
@@ -1,16 +1,31 @@
1
1
  # Getty Images API Ruby SDK
2
2
  [![Build Status](https://travis-ci.org/gettyimages/gettyimages-api_ruby.svg?branch=master)](https://travis-ci.org/gettyimages/gettyimages-api_ruby)
3
- Seamlessly integrate Getty Images' expansive digital content, powerful search technology, and rich metadata into your publishing tools, products and services!
4
3
 
5
- - Search for images and videos from our extensive creative and editorial catalogs.
6
- - Get image and video metadata.
7
- - Download files using your Getty Images products (e.g., Editorial subscriptions, Easy Access, Thinkstock Subscriptions, and Image Packs).
8
- - Custom Request functionality that allows user to call any endpoint.
4
+ ## Introduction
5
+ This SDK makes using the Getty Images [API](http://developers.gettyimages.com) easy. It handles credential management, makes HTTP requests and is written with a fluent style in mind. For more info about the API, see the [Documentation](https://developers.gettyimages.com/api/).
9
6
 
10
- ## Requirements
7
+ * Search for images and videos from our extensive creative and editorial catalogs.
8
+ * Get image and video metadata.
9
+ * Download files using your Getty Images products (e.g., Editorial subscriptions, Easy Access, Thinkstock Subscriptions, and Image Packs).
10
+ * Custom Request functionality that allows user to call any endpoint.
11
11
 
12
- - Ruby version >= 2.4
13
- - [Bundler](http://bundler.io)
12
+ ## Help & Support
13
+
14
+ * [Getty Images API](http://developers.gettyimages.com/)
15
+ * [Issue Tracker](https://github.com/gettyimages/gettyimages-api_ruby/issues)
16
+
17
+ ## Getting started
18
+
19
+ ### Obtain an API Key
20
+
21
+ If you don't already have an API key, fill out and submit the [contact form](http://engage.gettyimages.com/api-contact) to be connected to our Sales team.
22
+
23
+ ### Installing the ruby gem package
24
+
25
+ The SDK is available as a [ruby gem](https://rubygems.org/gems/gettyimages-api) package. Install in your workspace with:
26
+ ```sh
27
+ gem install gettyimages-api
28
+ ```
14
29
 
15
30
  ## Examples
16
31
 
@@ -135,8 +150,13 @@ result = apiClient
135
150
 
136
151
  puts result["id"]
137
152
  ```
153
+ ## Running Source Code
154
+ _Source code is only needed if you would like to contribute to the project. Otherwise, use the [ruby gem](https://rubygems.org/gems/gettyimages-api)_
138
155
 
139
- ## Unit Tests
156
+ ### Requirements
157
+
158
+ - Ruby version >= 2.5
159
+ - [Bundler](http://bundler.io)
140
160
 
141
161
  Install bundler and all dependencies
142
162
 
@@ -145,6 +165,8 @@ gem install bundler
145
165
  bundle install
146
166
  ```
147
167
 
168
+ ### Unit Tests
169
+
148
170
  To execute all unit tests:
149
171
 
150
172
  ```sh
@@ -6,7 +6,6 @@ require_relative 'lib/GettyImagesApi/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "gettyimages-api"
8
8
  spec.version = GettyImagesApi::VERSION
9
- spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
10
9
  spec.authors = ["Getty Images"]
11
10
  spec.email = ["developersupport@gettyimages.com"]
12
11
  spec.summary = "Getty Images API SDK"
data/lib/Credentials.rb CHANGED
@@ -13,18 +13,31 @@ class Credentials
13
13
  attr_accessor :client_secret
14
14
  attr_accessor :user_name
15
15
  attr_accessor :password
16
+ attr_accessor :token_details
16
17
 
17
18
  def initialize(args)
18
19
  args.keys.each { |name| instance_variable_set "@" + name.to_s, args[name] }
20
+ @token_details = nil
19
21
  end
20
22
 
21
23
  def get_uri(path)
22
24
  return URI.parse "#{Api_Host::API_BASE_URL}#{path}"
23
25
  end
24
26
 
27
+ def token_has_expired()
28
+ if (!token_details.nil?) && (@token_details.has_key?("sdk_expire_time"))
29
+ return @token_details["sdk_expire_time"] < (Time.now - 300)
30
+ end
31
+ return true
32
+ end
33
+
25
34
  # Get Access Token Using OAuth
26
35
  def get_access_token
27
36
 
37
+ if (!token_has_expired())
38
+ return @token_details["access_token"]
39
+ end
40
+
28
41
  # Determine OAuth Flow
29
42
  case @credential_type
30
43
  when OAuthGrantType::PASSWORD
@@ -62,6 +75,11 @@ class Credentials
62
75
  if !res.is_a?(Net::HTTPSuccess)
63
76
  raise res.code + ": " + result['error_description']
64
77
  end
78
+
79
+ @token_details = result
80
+ expiry = token_details["expires_in"].to_i
81
+ @token_details["sdk_expire_time"] = Time.now + expiry
82
+
65
83
  return result['access_token']
66
84
  end
67
85
 
@@ -2,7 +2,7 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class CustomRequest < RequestBase
4
4
 
5
- attr_accessor :method, :body, :route
5
+ attr_accessor :method, :body, :route, :headers
6
6
  # @route = "/v3/"
7
7
 
8
8
  def initialize(api_key, access_token)
@@ -13,13 +13,13 @@ class CustomRequest < RequestBase
13
13
  def execute
14
14
  case @method
15
15
  when "GET"
16
- return @http_helper.get(@route, @query_params)
16
+ return @http_helper.get(@route, @query_params, self.headers)
17
17
  when "POST"
18
- return @http_helper.post(@route, @query_params, self.body)
18
+ return @http_helper.post(@route, @query_params, self.body, self.headers)
19
19
  when "PUT"
20
- return @http_helper.put(@route, @query_params, self.body)
20
+ return @http_helper.put(@route, @query_params, self.body, self.headers)
21
21
  when "DELETE"
22
- return @http_helper.delete(@route, @query_params)
22
+ return @http_helper.delete(@route, @query_params, self.headers)
23
23
  else
24
24
  raise "No appropriate HTTP method found for this request."
25
25
  end
@@ -60,4 +60,9 @@ class CustomRequest < RequestBase
60
60
  return self
61
61
  end
62
62
 
63
+ def with_headers(headers)
64
+ self.headers = headers
65
+ return self
66
+ end
67
+
63
68
  end
@@ -2,7 +2,7 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class DownloadImages < RequestBase
4
4
 
5
- attr_accessor :asset_id
5
+ attr_accessor :asset_id, :accept_language
6
6
 
7
7
  API_ROUTE = "/v3/downloads/images" # mashery endpoint
8
8
  QUERY_PARAMS_NAMES = ["file_type","height","product_id","product_type"]
@@ -23,10 +23,16 @@ class DownloadImages < RequestBase
23
23
  return self
24
24
  end
25
25
 
26
+ public
27
+ def with_accept_language(language)
28
+ @accept_language = {"Accept-Language" => language}
29
+ return self
30
+ end
31
+
26
32
  def execute
27
33
  build_query_params("auto_download", "false")
28
34
  uri = API_ROUTE + "/" + self.asset_id
29
- return @http_helper.post(uri, @query_params, nil)
35
+ return @http_helper.post(uri, @query_params, nil, accept_language)
30
36
  end
31
37
 
32
38
  end
@@ -2,7 +2,7 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class DownloadVideos < RequestBase
4
4
 
5
- attr_accessor :asset_id
5
+ attr_accessor :asset_id, :accept_language
6
6
 
7
7
  API_ROUTE = "/v3/downloads/videos" # mashery endpoint
8
8
  QUERY_PARAMS_NAMES = ["product_id","size"]
@@ -23,10 +23,16 @@ class DownloadVideos < RequestBase
23
23
  return self
24
24
  end
25
25
 
26
+ public
27
+ def with_accept_language(language)
28
+ @accept_language = {"Accept-Language" => language}
29
+ return self
30
+ end
31
+
26
32
  def execute
27
33
  build_query_params("auto_download", "false")
28
34
  uri = API_ROUTE + "/" + self.asset_id
29
- return @http_helper.post(uri, @query_params, nil)
35
+ return @http_helper.post(uri, @query_params, nil, accept_language)
30
36
  end
31
37
 
32
38
  end
@@ -1,3 +1,3 @@
1
1
  module GettyImagesApi
2
- VERSION = "2.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
data/lib/HttpHelper.rb CHANGED
@@ -20,7 +20,7 @@ class HttpHelper
20
20
  return URI.parse "#{Api_Host::API_BASE_URL}#{path}"
21
21
  end
22
22
 
23
- def get(endpoint_path, query_params)
23
+ def get(endpoint_path, query_params, headers = nil)
24
24
 
25
25
  uri = get_uri(endpoint_path)
26
26
  #puts uri
@@ -29,11 +29,11 @@ class HttpHelper
29
29
  end
30
30
  #puts "REQUEST URI: #{uri.request_uri}"
31
31
  req = Net::HTTP::Get.new uri.request_uri
32
- return send uri, req, @api_key, @access_token
32
+ return send uri, req, @api_key, @access_token, headers
33
33
 
34
34
  end
35
35
 
36
- def post(endpoint_path, query_params, body)
36
+ def post(endpoint_path, query_params, body, headers = nil)
37
37
 
38
38
  uri = get_uri(endpoint_path)
39
39
  if !query_params.nil?
@@ -44,11 +44,11 @@ class HttpHelper
44
44
  req["Content-Type"] = "application/json"
45
45
  req.body = body.to_json
46
46
  end
47
- return send uri, req, @api_key, @access_token
47
+ return send uri, req, @api_key, @access_token, headers
48
48
 
49
49
  end
50
50
 
51
- def put(endpoint_path, query_params, body)
51
+ def put(endpoint_path, query_params, body, headers = nil)
52
52
 
53
53
  uri = get_uri(endpoint_path)
54
54
  if !query_params.nil?
@@ -59,18 +59,18 @@ class HttpHelper
59
59
  req["Content-Type"] = "application/json"
60
60
  req.body = body.to_json
61
61
  end
62
- return send uri, req, @api_key, @access_token
62
+ return send uri, req, @api_key, @access_token, headers
63
63
 
64
64
  end
65
65
 
66
- def delete(endpoint_path, query_params)
66
+ def delete(endpoint_path, query_params, headers = nil)
67
67
 
68
68
  uri = get_uri(endpoint_path)
69
69
  if !query_params.nil?
70
70
  uri.query = URI.encode_www_form query_params
71
71
  end
72
72
  req = Net::HTTP::Delete.new uri.request_uri
73
- return send uri, req, @api_key, @access_token
73
+ return send uri, req, @api_key, @access_token, headers
74
74
 
75
75
  end
76
76
 
@@ -93,7 +93,7 @@ class HttpHelper
93
93
  end
94
94
 
95
95
  private
96
- def send(uri, request, api_key, bearer_token = "")
96
+ def send(uri, request, api_key, bearer_token = "", headers)
97
97
 
98
98
  # define HTTPS connection
99
99
  https = Net::HTTP.new(uri.host, uri.port)
@@ -101,6 +101,7 @@ class HttpHelper
101
101
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
102
102
 
103
103
  # define headers
104
+ request.initialize_http_header(headers)
104
105
  request["User-Agent"] = "GettImagesApiSdk/#{GettyImagesApi::VERSION} (#{os} ; Ruby #{RUBY_VERSION})"
105
106
  request["Api-Key"] = api_key
106
107
  request["Authorization"] = "Bearer #{bearer_token}" unless bearer_token.empty?
data/lib/Images/Images.rb CHANGED
@@ -2,7 +2,7 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class Images < RequestBase
4
4
 
5
- attr_accessor :asset_id
5
+ attr_accessor :asset_id, :accept_language
6
6
 
7
7
  API_ROUTE = "/v3/images" # mashery endpoint
8
8
  QUERY_PARAMS_NAMES = ["ids","fields"]
@@ -24,10 +24,16 @@ class Images < RequestBase
24
24
  return self
25
25
  end
26
26
 
27
+ public
28
+ def with_accept_language(language)
29
+ @accept_language = {"Accept-Language" => language}
30
+ return self
31
+ end
32
+
27
33
  public
28
34
  def execute
29
35
  self.asset_id.nil? ? uri = API_ROUTE : uri = API_ROUTE + "/" + self.asset_id
30
- return @http_helper.get(uri, @query_params)
36
+ return @http_helper.get(uri, @query_params, @accept_language)
31
37
  end
32
38
 
33
39
  end
@@ -2,9 +2,11 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class SearchImages < RequestBase
4
4
 
5
- API_ROUTE = "/v3/search/images" # mashery endpoint
5
+ attr_accessor :accept_language
6
+
7
+ API_ROUTE = "/v3/search/images" # mashery endpoint
6
8
  QUERY_PARAMS_NAMES = ["age_of_people","artists","collection_codes","collections_filter_type","color","compositions","embed_content_only","ethnicity","event_ids","exclude_nudity","fields",
7
- "file_types","graphical_styles","keyword_ids","license_models","minimum_size","number_of_people","orientations","page","page_size","phrase","prestige_content_only","product_types",
9
+ "file_types","graphical_styles","keyword_ids","minimum_size","number_of_people","orientations","page","page_size","phrase","prestige_content_only","product_types",
8
10
  "sort_order","specific_people"]
9
11
 
10
12
  QUERY_PARAMS_NAMES.each do |key|
@@ -23,10 +25,15 @@ class SearchImages < RequestBase
23
25
  end
24
26
  return self
25
27
  end
26
- end
28
+ end
29
+
30
+ def with_accept_language(language)
31
+ @accept_language = {"Accept-Language" => language}
32
+ return self
33
+ end
27
34
 
28
35
  def execute
29
- return @http_helper.get(API_ROUTE, @query_params)
36
+ return @http_helper.get(API_ROUTE, @query_params, @accept_language)
30
37
  end
31
38
 
32
39
  end
@@ -2,9 +2,11 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class SearchImagesCreative < RequestBase
4
4
 
5
+ attr_accessor :accept_language
6
+
5
7
  API_ROUTE = "/v3/search/images/creative" # mashery endpoint
6
8
  QUERY_PARAMS_NAMES = ["age_of_people","artists","collection_codes","collections_filter_type","color","compositions","embed_content_only","ethnicity","exclude_nudity","fields","file_types",
7
- "graphical_styles","keyword_ids","license_models","minimum_size","number_of_people","orientations","page","page_size","phrase","prestige_content_only","product_types",
9
+ "graphical_styles","keyword_ids","minimum_size","number_of_people","orientations","page","page_size","phrase","prestige_content_only","product_types",
8
10
  "sort_order"]
9
11
 
10
12
  QUERY_PARAMS_NAMES.each do |key|
@@ -23,10 +25,15 @@ class SearchImagesCreative < RequestBase
23
25
  end
24
26
  return self
25
27
  end
26
- end
28
+ end
29
+
30
+ def with_accept_language(language)
31
+ @accept_language = {"Accept-Language" => language}
32
+ return self
33
+ end
27
34
 
28
35
  def execute
29
- return @http_helper.get(API_ROUTE, @query_params)
36
+ return @http_helper.get(API_ROUTE, @query_params, @accept_language)
30
37
  end
31
38
 
32
39
  end
@@ -2,6 +2,8 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class SearchImagesEditorial < RequestBase
4
4
 
5
+ attr_accessor :accept_language
6
+
5
7
  API_ROUTE = "/v3/search/images/editorial" # mashery endpoint
6
8
  QUERY_PARAMS_NAMES = ["age_of_people","artists","collection_codes","collections_filter_type","compositions","editorial_segments","embed_content_only","end_date","entity_uris","ethnicity",
7
9
  "event_ids","exclude_nudity","fields","file_types","graphical_styles","keyword_ids","minimum_quality_rank","minimum_size","number_of_people","orientations","page","page_size","phrase",
@@ -23,10 +25,15 @@ class SearchImagesEditorial < RequestBase
23
25
  end
24
26
  return self
25
27
  end
26
- end
28
+ end
27
29
 
30
+ def with_accept_language(language)
31
+ @accept_language = {"Accept-Language" => language}
32
+ return self
33
+ end
34
+
28
35
  def execute
29
- return @http_helper.get(API_ROUTE, @query_params)
36
+ return @http_helper.get(API_ROUTE, @query_params, @accept_language)
30
37
  end
31
38
 
32
39
  end
@@ -2,6 +2,8 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class SearchVideos < RequestBase
4
4
 
5
+ attr_accessor :accept_language
6
+
5
7
  API_ROUTE = "/v3/search/videos" # mashery endpoint
6
8
  QUERY_PARAMS_NAMES = ["age_of_people","collection_codes","collections_filter_type","editorial_video_types","exclude_nudity","fields","format_available","frame_rates",
7
9
  "keyword_ids","license_models","page","page_size","phrase","product_types","sort_order","specific_people"]
@@ -22,10 +24,15 @@ class SearchVideos < RequestBase
22
24
  end
23
25
  return self
24
26
  end
25
- end
27
+ end
28
+
29
+ def with_accept_language(language)
30
+ @accept_language = {"Accept-Language" => language}
31
+ return self
32
+ end
26
33
 
27
34
  def execute
28
- return @http_helper.get(API_ROUTE, @query_params)
35
+ return @http_helper.get(API_ROUTE, @query_params, @accept_language)
29
36
  end
30
37
 
31
38
  end
@@ -2,6 +2,8 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class SearchVideosCreative < RequestBase
4
4
 
5
+ attr_accessor :accept_language
6
+
5
7
  API_ROUTE = "/v3/search/videos/creative" # mashery endpoint
6
8
  QUERY_PARAMS_NAMES = ["age_of_people","collection_codes","collections_filter_type","exclude_nudity","fields","format_available","frame_rates",
7
9
  "keyword_ids","license_models","page","page_size","phrase","product_types","sort_order"]
@@ -22,10 +24,15 @@ class SearchVideosCreative < RequestBase
22
24
  end
23
25
  return self
24
26
  end
25
- end
27
+ end
28
+
29
+ def with_accept_language(language)
30
+ @accept_language = {"Accept-Language" => language}
31
+ return self
32
+ end
26
33
 
27
34
  def execute
28
- return @http_helper.get(API_ROUTE, @query_params)
35
+ return @http_helper.get(API_ROUTE, @query_params, @accept_language)
29
36
  end
30
37
 
31
38
  end
@@ -2,6 +2,8 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class SearchVideosEditorial < RequestBase
4
4
 
5
+ attr_accessor :accept_language
6
+
5
7
  API_ROUTE = "/v3/search/videos/editorial" # mashery endpoint
6
8
  QUERY_PARAMS_NAMES = ["age_of_people","collection_codes","collections_filter_type","editorial_video_types","entity_uris","exclude_nudity","fields","format_available","frame_rates",
7
9
  "keyword_ids","page","page_size","phrase","product_types","sort_order","specific_people"]
@@ -24,8 +26,13 @@ class SearchVideosEditorial < RequestBase
24
26
  end
25
27
  end
26
28
 
29
+ def with_accept_language(language)
30
+ @accept_language = {"Accept-Language" => language}
31
+ return self
32
+ end
33
+
27
34
  def execute
28
- return @http_helper.get(API_ROUTE, @query_params)
35
+ return @http_helper.get(API_ROUTE, @query_params, @accept_language)
29
36
  end
30
37
 
31
38
  end
data/lib/Videos/Videos.rb CHANGED
@@ -2,7 +2,7 @@ require_relative "../RequestBase.rb"
2
2
 
3
3
  class Videos < RequestBase
4
4
 
5
- attr_accessor :asset_id
5
+ attr_accessor :asset_id, :accept_language
6
6
 
7
7
  API_ROUTE = "/v3/videos" # mashery endpoint
8
8
  QUERY_PARAMS_NAMES = ["ids","fields"]
@@ -24,10 +24,16 @@ class Videos < RequestBase
24
24
  return self
25
25
  end
26
26
 
27
+ public
28
+ def with_accept_language(language)
29
+ @accept_language = {"Accept-Language" => language}
30
+ return self
31
+ end
32
+
27
33
  public
28
34
  def execute
29
35
  self.asset_id.nil? ? uri = API_ROUTE : uri = API_ROUTE + "/" + self.asset_id
30
- return @http_helper.get(uri, @query_params)
36
+ return @http_helper.get(uri, @query_params, @accept_language)
31
37
  end
32
38
 
33
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettyimages-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Getty Images
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-05 00:00:00.000000000 Z
11
+ date: 2021-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,12 +45,15 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/build.yml"
49
+ - ".github/workflows/publish.yml"
48
50
  - ".gitignore"
49
51
  - ".vscode/launch.json"
50
52
  - ".vscode/tasks.json"
51
53
  - Gemfile
52
54
  - Gemfile.lock
53
55
  - LICENSE
56
+ - Makefile
54
57
  - README.md
55
58
  - Rakefile
56
59
  - gettyimages-api.gemspec
@@ -59,7 +62,6 @@ files:
59
62
  - lib/CustomRequest/CustomRequest.rb
60
63
  - lib/Downloads/DownloadImages.rb
61
64
  - lib/Downloads/DownloadVideos.rb
62
- - lib/Example.rb
63
65
  - lib/GettyImagesApi/version.rb
64
66
  - lib/HttpHelper.rb
65
67
  - lib/Images/Images.rb
@@ -92,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
94
  version: '0'
93
95
  requirements: []
94
96
  rubyforge_project:
95
- rubygems_version: 2.5.2
97
+ rubygems_version: 2.7.6.3
96
98
  signing_key:
97
99
  specification_version: 4
98
100
  summary: Getty Images API SDK
data/lib/Example.rb DELETED
@@ -1,21 +0,0 @@
1
- require "pp"
2
- require_relative "GettyImagesApi"
3
-
4
- api_key = "api key"
5
- api_secret = "api secret"
6
-
7
- apiClient = GettyImagesApi.new(api_key, api_secret)
8
- search_results = apiClient.search().images().creative()
9
- .with_phrase("gorilla")
10
- .with_response_fields(["id","title"])
11
- .with_graphical_styles("illustration")
12
- .with_graphical_styles(["fine_art","photography"])
13
- .with_page(2)
14
- .with_page_size(5)
15
- .execute()
16
-
17
- search_results["images"].each do | image |
18
- puts "Id: #{image["id"]} Title: #{image["title"]}"
19
- end
20
-
21
-