gettyimages-api 2.0.3.pre.alpha.pre.17 → 2.0.4
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 +28 -9
- data/gettyimages-api.gemspec +0 -1
- data/lib/Credentials.rb +18 -0
- data/lib/GettyImagesApi/version.rb +1 -1
- metadata +4 -5
- data/lib/Example.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482643d3ef1c6faa8ed02ff34ea5b71f291c0617564431312b2be679a93d465f
|
4
|
+
data.tar.gz: 4cbf5f76b5501363a82e9500a382895c49ce9044ae277a1342fe592e2364f0d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9698e689db7edfc4e72fc0ff004284215780ca39e78308459af69b4623d6b75a759b2673132ae46babad2620d0b49f743cbb77ffbf7c75d345fe6732648f35
|
7
|
+
data.tar.gz: b0caca61c415a12f2c3da88c42a35dcd4b08b4d94a9a9abc96b168fdffe5e8e4faede238f3da8a9d9eb902d310015210e82ee14d0620c34b11f030ee77bf1c2c
|
data/README.md
CHANGED
@@ -1,16 +1,28 @@
|
|
1
1
|
# Getty Images API Ruby SDK
|
2
2
|
[](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
|
-
|
6
|
-
|
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
|
-
|
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
|
-
|
13
|
-
|
12
|
+
## Help & Support
|
13
|
+
|
14
|
+
* [Getty Images API](http://developers.gettyimages.com/)
|
15
|
+
* [Contact Developer Support](mailto:developersupport@gettyimages.com)
|
16
|
+
* [Issue Tracker](https://github.com/gettyimages/gettyimages-api_ruby/issues)
|
17
|
+
|
18
|
+
## Getting started
|
19
|
+
|
20
|
+
### Installing the ruby gem package
|
21
|
+
|
22
|
+
The SDK is available as a [ruby gem](https://rubygems.org/gems/gettyimages-api) package. Install in your workspace with:
|
23
|
+
```sh
|
24
|
+
gem install gettyimages-api
|
25
|
+
```
|
14
26
|
|
15
27
|
## Examples
|
16
28
|
|
@@ -135,8 +147,13 @@ result = apiClient
|
|
135
147
|
|
136
148
|
puts result["id"]
|
137
149
|
```
|
150
|
+
## Running Source Code
|
151
|
+
_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)_
|
152
|
+
|
153
|
+
### Requirements
|
138
154
|
|
139
|
-
|
155
|
+
- Ruby version >= 2.4
|
156
|
+
- [Bundler](http://bundler.io)
|
140
157
|
|
141
158
|
Install bundler and all dependencies
|
142
159
|
|
@@ -145,6 +162,8 @@ gem install bundler
|
|
145
162
|
bundle install
|
146
163
|
```
|
147
164
|
|
165
|
+
### Unit Tests
|
166
|
+
|
148
167
|
To execute all unit tests:
|
149
168
|
|
150
169
|
```sh
|
data/gettyimages-api.gemspec
CHANGED
@@ -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
|
|
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.
|
4
|
+
version: 2.0.4
|
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-
|
11
|
+
date: 2018-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -59,7 +59,6 @@ files:
|
|
59
59
|
- lib/CustomRequest/CustomRequest.rb
|
60
60
|
- lib/Downloads/DownloadImages.rb
|
61
61
|
- lib/Downloads/DownloadVideos.rb
|
62
|
-
- lib/Example.rb
|
63
62
|
- lib/GettyImagesApi/version.rb
|
64
63
|
- lib/HttpHelper.rb
|
65
64
|
- lib/Images/Images.rb
|
@@ -87,9 +86,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
86
|
version: '0'
|
88
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
88
|
requirements:
|
90
|
-
- - "
|
89
|
+
- - ">="
|
91
90
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
91
|
+
version: '0'
|
93
92
|
requirements: []
|
94
93
|
rubyforge_project:
|
95
94
|
rubygems_version: 2.7.6
|
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
|
-
|