Skip to content

Commit

Permalink
Remove all references to "Connect"
Browse files Browse the repository at this point in the history
Add task to run tests in VS Code
  • Loading branch information
mapitman committed Apr 3, 2018
1 parent 7c8d92c commit 5bd0faa
Show file tree
Hide file tree
Showing 33 changed files with 459 additions and 466 deletions.
15 changes: 15 additions & 0 deletions .vscode/tasks.json
@@ -0,0 +1,15 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "test",
"type": "shell",
"command": "ruby",
"args": [
"./unit_tests/Run.rb"
],
}
]
}
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Getty Images
Copyright (c) 2014-2018 Getty Images

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 0 additions & 22 deletions LICENSE.txt

This file was deleted.

199 changes: 109 additions & 90 deletions README.md
@@ -1,4 +1,4 @@
# Getty Images Connect SDK
# Getty Images API Ruby SDK

Seamlessly integrate Getty Images' expansive digital content, powerful search technology, and rich metadata into your publishing tools, products and services!

Expand All @@ -8,132 +8,151 @@ Seamlessly integrate Getty Images' expansive digital content, powerful search te
- Custom Request functionality that allows user to call any endpoint.

## Requirements

- Ruby version > 2.4
- [Bundler](http://bundler.io)

## Examples

### Search for one or more images

```ruby
require "ConnectSdk"

api_key = "Connect API Key"
api_secret = "Connect API Secret"

# create instance of the Connect SDK
connectSdk = ConnectSdk.new(api_key, api_secret)
results = connectSdk
.search_images()
.with_phrase("gorilla")
.with_fields(["artist", "id", "title"])
.with_exclude_nudity("true")
.with_page(2)
.with_page_size(5)
.execute()
results["images"].each do | image |
puts "Id: #{image["id"]} Title: #{image["title"]}"
require "GettyImagesApi"

api_key = "API Key"
api_secret = "API Secret"

# create instance of the SDK
apiClient = ApiClient.new(api_key, api_secret)
result = apiClient
.search_images()
.with_phrase("gorilla")
.with_fields(["artist", "id", "title"])
.with_exclude_nudity("true")
.with_page(2)
.with_page_size(5)
.execute()

result["images"].each do | image |
puts "Id: #{image["id"]} Title: #{image["title"]}"
end
```

### Get detailed information for one image

```ruby
require "ConnectSdk"

api_key = "Connect API Key"
api_secret = "Connect API Secret"

# create instance of the Connect SDK
connectSdk = ConnectSdk.new(api_key, api_secret)
result = connectSdk
.images()
.with_id("ASSET_ID")
.execute()
require "GettyImagesApi"

api_key = "API Key"
api_secret = "API Secret"

# create instance of the SDK
apiClient = ApiClient.new(api_key, api_secret)
result = apiClient
.images()
.with_id("ASSET_ID")
.execute()

puts result
```

### Get detailed information for multiple images

```ruby
require "ConnectSdk"

api_key = "Connect API Key"
api_secret = "Connect API Secret"

# create instance of the Connect SDK
connectSdk = ConnectSdk.new(api_key, api_secret)
results = connectSdk
.images()
.with_ids(["ASSET_ID_1", "ASSET_ID_2"])
.execute()
results["images"].each do | image |
require "GettyImagesApi"

api_key = "API Key"
api_secret = "API Secret"

# create instance of the SDK
apiClient = ApiClient.new(api_key, api_secret)
result = apiClient
.images()
.with_ids(["ASSET_ID_1", "ASSET_ID_2"])
.execute()

result["images"].each do | image |
puts image
end
```

### Download an image

```ruby
require "ConnectSdk"

api_key = "Connect API Key"
api_secret = "Connect API Secret"

# create instance of the Connect SDK
connectSdk = ConnectSdk.new(api_key, api_secret)
result = connectSdk
.download_images()
.with_id("ASSET_ID")
.execute()
require "GettyImagesApi"

api_key = "API Key"
api_secret = "API Secret"

# create instance of the SDK
apiClient = ApiClient.new(api_key, api_secret)
result = apiClient
.download_images()
.with_id("ASSET_ID")
.execute()

puts result["uri"]
```

### Use the custom request functionality for GET request with query parameters

```ruby
require "ConnectSdk"

api_key = "Connect API Key"
api_secret = "Connect API Secret"

# create instance of the Connect SDK
connectSdk = ConnectSdk.new(api_key, api_secret)
results = connectSdk
.custom_request()
.with_method("GET")
.with_route("search/images")
.with_query_parameters({"phrase"=> "cat", "fields"=> ["artist", "id", "title"], "page" => 2})
.execute()
results["images"].each do | image |
puts "Id: #{image["id"]} Title: #{image["title"]}"
require "GettyImagesApi"

api_key = "API Key"
api_secret = "API Secret"

# create instance of the SDK
apiClient = ApiClient.new(api_key, api_secret)
result = apiClient
.custom_request()
.with_method("GET")
.with_route("search/images")
.with_query_parameters({"phrase"=> "cat", "fields"=> ["artist", "id", "title"], "page" => 2})
.execute()

result["images"].each do | image |
puts "Id: #{image["id"]} Title: #{image["title"]}"
end
```

### Use the custom request functionality for POST request with body

```ruby
require "ConnectSdk"

api_key = "Connect API Key"
api_secret = "Connect API Secret"

# create instance of the Connect SDK
connectSdk = ConnectSdk.new(api_key, api_secret)
result = connectSdk
.custom_request()
.with_method("POST")
.with_route("boards")
.with_body({"name"=> "Board Name", "description" => "Board Description"})
.execute()
require "GettyImagesApi"

api_key = "API Key"
api_secret = "API Secret"

# create instance of the SDK
apiClient = ApiClient.new(api_key, api_secret)
result = apiClient
.custom_request()
.with_method("POST")
.with_route("boards")
.with_body({"name"=> "Board Name", "description" => "Board Description"})
.execute()

puts result["id"]
```

## Unit Tests

To execute all unit tests:
Install bundler and all dependencies

```sh
gem install bundler
bundle install
```

To execute all unit tests:

$ ruby unit_tests/Run.rb
```sh
rake
```

To run one unit test file:

$ ruby unit_tests/FILENAME.rb
```sh
ruby unit_tests/FILENAME.rb
```
3 changes: 1 addition & 2 deletions Rakefile
@@ -1,6 +1,5 @@
# require "bundler"
require "bundler"
require "bundler/gem_tasks"

require "rake/testtask"

task :test do
Expand Down
8 changes: 4 additions & 4 deletions gettyimages-api.gemspec
@@ -1,16 +1,16 @@
# coding: utf-8
lib = File.expand_path('lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require_relative 'lib/ConnectSDK/version'
require_relative 'lib/GettyImagesApi/version'

Gem::Specification.new do |spec|
spec.name = "gettyimages-api"
spec.version = ConnectSDK::VERSION
spec.authors = ["Rod Santos, Lisa Guo, Stephanie Sterling"]
spec.version = GettyImagesApi::VERSION
spec.authors = ["Getty Images"]
spec.email = ["developersupport@gettyimages.com"]
spec.summary = "Getty Images API SDK"
spec.description = "Getty Images API SDK"
spec.homepage = "https://api.gettyimages.com/swagger"
spec.homepage = "https://github.com/gettyimages/gettyimages-api_ruby"
spec.license = "MIT"
gem_files = `git ls-files -z`.split("\x0")
gem_ignored_files = `git ls-files -z unit_tests/`.split("\x0")
Expand Down
12 changes: 1 addition & 11 deletions lib/ConnectSDK.rb → lib/ApiClient.rb
@@ -1,9 +1,3 @@
# Connect SDK by Getty Images.
# Provides an interface to Getty Images connect api.
#
# The goal of the SDK is to simplify credential management and provide a reusable library
# for developers.

require_relative "Credentials"
require_relative "Search/SearchImages.rb"
require_relative "Search/SearchImagesCreative.rb"
Expand All @@ -17,11 +11,7 @@
require_relative "Videos/Videos.rb"
require_relative "CustomRequest/CustomRequest.rb"

# ConnectSDK
# Provides a code api for interacting with getty rest services.
# {https://connect.gettyimages.com/swagger/ui/index.html Connect Getty Images API}

class ConnectSdk
class ApiClient

# Initialize the Credentials to be used by the SDK
def initialize(api_key, api_secret, user_name = nil, password = nil)
Expand Down
3 changes: 0 additions & 3 deletions lib/ConnectSDK/version.rb

This file was deleted.

4 changes: 2 additions & 2 deletions lib/Credentials.rb
Expand Up @@ -19,10 +19,10 @@ def initialize(args)
end

def get_uri(path)
return URI.parse "#{Connect_Api_Host::API_BASE_URL}#{path}"
return URI.parse "#{Api_Host::API_BASE_URL}#{path}"
end

# Get Access Token Using Connect API OAuth
# Get Access Token Using OAuth
def get_access_token

# Determine OAuth Flow
Expand Down
4 changes: 2 additions & 2 deletions lib/Downloads/DownloadImages.rb
Expand Up @@ -4,7 +4,7 @@ class DownloadImages < RequestBase

attr_accessor :asset_id

CONNECT_ROUTE = "/v3/downloads/images" # mashery endpoint
API_ROUTE = "/v3/downloads/images" # mashery endpoint
QUERY_PARAMS_NAMES = ["file_type","height","product_id","product_type"]

QUERY_PARAMS_NAMES.each do |key|
Expand All @@ -25,7 +25,7 @@ def with_id(asset_id)

def execute
build_query_params("auto_download", "false")
uri = CONNECT_ROUTE + "/" + self.asset_id
uri = API_ROUTE + "/" + self.asset_id
return @http_helper.post(uri, @query_params, nil)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/Downloads/DownloadVideos.rb
Expand Up @@ -4,7 +4,7 @@ class DownloadVideos < RequestBase

attr_accessor :asset_id

CONNECT_ROUTE = "/v3/downloads/videos" # mashery endpoint
API_ROUTE = "/v3/downloads/videos" # mashery endpoint
QUERY_PARAMS_NAMES = ["product_id","size"]

QUERY_PARAMS_NAMES.each do |key|
Expand All @@ -25,7 +25,7 @@ def with_id(asset_id)

def execute
build_query_params("auto_download", "false")
uri = CONNECT_ROUTE + "/" + self.asset_id
uri = API_ROUTE + "/" + self.asset_id
return @http_helper.post(uri, @query_params, nil)
end

Expand Down

0 comments on commit 5bd0faa

Please sign in to comment.