zara4 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/lib/zara4.rb +4 -0
  3. data/lib/zara4/api.rb +7 -0
  4. data/lib/zara4/api/client.rb +87 -0
  5. data/lib/zara4/api/communication.rb +8 -0
  6. data/lib/zara4/api/communication/access_token.rb +6 -0
  7. data/lib/zara4/api/communication/access_token/access_token.rb +46 -0
  8. data/lib/zara4/api/communication/access_token/refreshable_access_token.rb +30 -0
  9. data/lib/zara4/api/communication/access_token/reissuable_access_token.rb +29 -0
  10. data/lib/zara4/api/communication/authentication.rb +6 -0
  11. data/lib/zara4/api/communication/authentication/application_authenticator.rb +20 -0
  12. data/lib/zara4/api/communication/authentication/authenticator.rb +35 -0
  13. data/lib/zara4/api/communication/authentication/user_authenticator.rb +34 -0
  14. data/lib/zara4/api/communication/config.rb +37 -0
  15. data/lib/zara4/api/communication/grant.rb +7 -0
  16. data/lib/zara4/api/communication/grant/client_credentials_grant_request.rb +14 -0
  17. data/lib/zara4/api/communication/grant/grant_request.rb +72 -0
  18. data/lib/zara4/api/communication/grant/password_grant.rb +33 -0
  19. data/lib/zara4/api/communication/grant/refresh_token_grant.rb +31 -0
  20. data/lib/zara4/api/communication/util.rb +29 -0
  21. data/lib/zara4/api/image_processing.rb +12 -0
  22. data/lib/zara4/api/image_processing/colour_enhancement.rb +5 -0
  23. data/lib/zara4/api/image_processing/local_image_request.rb +19 -0
  24. data/lib/zara4/api/image_processing/optimisation_mode.rb +5 -0
  25. data/lib/zara4/api/image_processing/output_format.rb +5 -0
  26. data/lib/zara4/api/image_processing/processed_image.rb +57 -0
  27. data/lib/zara4/api/image_processing/remote_image_request.rb +19 -0
  28. data/lib/zara4/api/image_processing/request.rb +63 -0
  29. data/lib/zara4/api/image_processing/resize_mode.rb +6 -0
  30. metadata +101 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9d32423b639f5193d153d441806f19a314968b6b
4
+ data.tar.gz: de8634c5f3bcdd306c9254452b4cfa39b8bda8f9
5
+ SHA512:
6
+ metadata.gz: c39686f4b9ca25ca50b75ba9c710d2ce96329633c9187ae8e9fd420c5e0f31b6d9837ba37243b09c8b28ce5ace090721b4ee673cde7f0cddeb91b5a0480129fa
7
+ data.tar.gz: 43135d4e0a880eb2a55e75109eb8e2a252b2bf10441a99331725b11dbe84f1d4a70afb9bdf1ed998c4ca1adca69fc0d38ead770bb109b5dc17983101a06279a0
@@ -0,0 +1,4 @@
1
+ module Zara4
2
+ end
3
+
4
+ require_relative './zara4/api.rb'
@@ -0,0 +1,7 @@
1
+ module Zara4::API
2
+ VERSION = '1.0.0'
3
+ end
4
+
5
+ require_relative './api/client.rb'
6
+ require_relative './api/image_processing.rb'
7
+ require_relative './api/communication.rb'
@@ -0,0 +1,87 @@
1
+ require 'json'
2
+ require 'open-uri'
3
+ require 'httmultiparty'
4
+
5
+ module Zara4::API
6
+ class Client
7
+ include HTTMultiParty
8
+
9
+ attr_accessor :client_id, :client_secret
10
+
11
+
12
+ #
13
+ # Application authenticated client.
14
+ #
15
+ def initialize(credentials)
16
+ @client_id = credentials.fetch('client_id')
17
+ @client_secret = credentials.fetch('client_secret')
18
+
19
+ if @client_id && @client_secret
20
+ authenticator = Zara4::API::Communication::Authentication::ApplicationAuthenticator.new(@client_id, @client_secret)
21
+ authenticator.with_image_processing().with_usage()
22
+ @access_token = authenticator.acquire_access_token()
23
+ end
24
+ end
25
+
26
+
27
+ #
28
+ # Process the given image processing Request.
29
+ #
30
+ # @param image_processing_request The request to be processed
31
+ #
32
+ def process_image(image_processing_request)
33
+ url = Zara4::API::Communication::Util::url('/v1/image-processing/request')
34
+
35
+ parameters = image_processing_request.generate_form_data
36
+
37
+ headers = {
38
+ 'access_token' => @access_token.token
39
+ }
40
+
41
+ print parameters
42
+
43
+ response = self.class.post(url, {
44
+ query: parameters,
45
+ headers: headers,
46
+ detect_mime_type: true
47
+ })
48
+
49
+
50
+ # Check for API error response
51
+ if response.has_key?('error')
52
+ raise 'ERROR IS ' + response.fetch('error')
53
+ end
54
+
55
+
56
+ request_id = response['request-id']
57
+ generate_images_urls = response['generated-images']['urls']
58
+ bytes_original = response['compression']['bytes-original']
59
+ bytes_compressed = response['compression']['bytes-compressed']
60
+
61
+ return Zara4::API::ImageProcessing::ProcessedImage.new(image_processing_request, request_id, generate_images_urls, bytes_original, bytes_compressed)
62
+ end
63
+
64
+
65
+ #
66
+ # Download the given ProcessedImage and save it to the given path.
67
+ #
68
+ # @param processed_image The ProcessedImage to be downloaded.
69
+ # @param save_path The path where the image should be saved.
70
+ #
71
+ def download_processed_image(processed_image, save_path)
72
+
73
+ url = processed_image.file_urls[0]
74
+
75
+ if @access_token
76
+ url += '?access_token' + @access_token.token()
77
+ end
78
+
79
+ File.open(save_path, "w") do |f|
80
+ IO.copy_stream(open(url), f)
81
+ end
82
+
83
+ end
84
+
85
+
86
+ end
87
+ end
@@ -0,0 +1,8 @@
1
+ module Zara4::API::Communication
2
+ end
3
+
4
+ require_relative './communication/config.rb'
5
+ require_relative './communication/util.rb'
6
+ require_relative './communication/access_token.rb'
7
+ require_relative './communication/authentication.rb'
8
+ require_relative './communication/grant.rb'
@@ -0,0 +1,6 @@
1
+ module Zara4::API::Communication::AccessToken
2
+ end
3
+
4
+ require_relative './access_token/access_token.rb'
5
+ require_relative './access_token/refreshable_access_token.rb'
6
+ require_relative './access_token/reissuable_access_token.rb'
@@ -0,0 +1,46 @@
1
+ module Zara4::API::Communication::AccessToken
2
+ class AccessToken
3
+
4
+ attr_accessor :client_id, :client_secret, :access_token, :expires_at
5
+
6
+
7
+ #
8
+ # Constructor
9
+ #
10
+ def initialize(client_id, client_secret, access_token, expires_at)
11
+ @client_id = client_id
12
+ @client_secret = client_secret
13
+ @access_token = access_token;
14
+ @expires_at = expires_at
15
+ end
16
+
17
+
18
+ #
19
+ # Get the token
20
+ #
21
+ def token
22
+ if has_expired()
23
+ refresh()
24
+ end
25
+ return @access_token
26
+ end
27
+
28
+
29
+ #
30
+ # Refresh this AccessToken
31
+ #
32
+ def refresh
33
+ # Stub to be implemented
34
+ end
35
+
36
+
37
+ #
38
+ # Has this AccessToken expired?
39
+ #
40
+ def has_expired
41
+ return Time.now > @expires_at
42
+ end
43
+
44
+
45
+ end
46
+ end
@@ -0,0 +1,30 @@
1
+ module Zara4::API::Communication::AccessToken
2
+ class RefreshableAccessToken < AccessToken
3
+
4
+ attr_accessor :refresh_token
5
+
6
+
7
+ #
8
+ # Constructor
9
+ #
10
+ def initialize(client_id, client_secret, access_token, expires_at, refesh_token)
11
+ super(client_id, client_secret, access_token, expires_at)
12
+ @refresh_token = refresh_token
13
+ end
14
+
15
+
16
+ #
17
+ # Refresh this ReissuableAccessToken
18
+ #
19
+ def refresh
20
+ grant = RefreshTokenGrant.new(@client_id, @client_secret, @refresh_token, [])
21
+ tokens = grant.get_tokens()
22
+
23
+ @access_token = tokens['access_tokens']
24
+ @expires_at = ''
25
+ @refresh_token = tokens['refresh_token']
26
+ end
27
+
28
+
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ module Zara4::API::Communication::AccessToken
2
+ class ReissuableAccessToken < AccessToken
3
+
4
+ attr_accessor :scopes
5
+
6
+
7
+ #
8
+ # Constructor
9
+ #
10
+ def initialize(client_id, client_secret, access_token, expires_at, scopes)
11
+ super(client_id, client_secret, access_token, expires_at)
12
+ @scopes = scopes
13
+ end
14
+
15
+
16
+ #
17
+ # Refresh this ReissuableAccessToken
18
+ #
19
+ def refresh
20
+ grant = ClientCredentialsGrantRequest.new(@client_id, @client_secret, @scopes)
21
+ tokens = grant.get_tokens()
22
+
23
+ @access_token = tokens['access_token']
24
+ @expires_at = tokens['expires_in']
25
+ end
26
+
27
+
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ module Zara4::API::Communication::Authentication
2
+ end
3
+
4
+ require_relative './authentication/authenticator.rb'
5
+ require_relative './authentication/application_authenticator.rb'
6
+ require_relative './authentication/user_authenticator.rb'
@@ -0,0 +1,20 @@
1
+ module Zara4::API::Communication::Authentication
2
+ class ApplicationAuthenticator < Authenticator
3
+
4
+
5
+ #
6
+ # Acquire an AccessToken using this ApplicationAuthenticator.
7
+ #
8
+ def acquire_access_token
9
+ grant = Zara4::API::Communication::Grant::ClientCredentialsGrantRequest.new(@client_id, @client_secret, @scopes)
10
+ tokens = grant.get_tokens()
11
+
12
+ access_token = tokens['access_token']
13
+ expires_at = Zara4::API::Communication::Util::calculate_expiry_time(tokens['expires_in'])
14
+
15
+ return Zara4::API::Communication::AccessToken::ReissuableAccessToken.new(@client_id, @client_secret, access_token, expires_at, @scopes)
16
+ end
17
+
18
+
19
+ end
20
+ end
@@ -0,0 +1,35 @@
1
+ module Zara4::API::Communication::Authentication
2
+ class Authenticator
3
+
4
+ attr_accessor :client_id, :client_secret
5
+
6
+ #
7
+ # Constructor
8
+ #
9
+ def initialize(client_id, client_secret)
10
+ @client_id = client_id
11
+ @client_secret = client_secret
12
+ @scopes = [];
13
+ end
14
+
15
+
16
+ #
17
+ # Add image processing to the Authenticator scope.
18
+ #
19
+ def with_image_processing
20
+ @scopes.push('image-processing')
21
+ return self
22
+ end
23
+
24
+
25
+ #
26
+ # Add reading account usage to the Authenticator scope.
27
+ #
28
+ def with_usage
29
+ @scopes.push('usage')
30
+ return self
31
+ end
32
+
33
+
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ module Zara4::API::Communication::Authentication
2
+ class UserAuthenticator < Authenticator
3
+
4
+
5
+ attr_accessor :client_id, :client_secret, :username, :password
6
+
7
+
8
+ #
9
+ # Constructor
10
+ #
11
+ def initialize(client_id, client_secret, username, password)
12
+ super.initialize(client_id, client_secret)
13
+ @username = username
14
+ @password = password
15
+ end
16
+
17
+
18
+ #
19
+ # Acquire an AccessToken using this UserAuthenticator.
20
+ #
21
+ def acquire_access_token
22
+ grant = Zara4::API::Communication::Grant::ClientCredentialsGrantRequest.new(@client_id, @clint_secret, @scopes)
23
+ tokens = grant.getTokens()
24
+
25
+ access_token = tokens['access_token']
26
+ refresh_token = tokens['refresh_token']
27
+ expires_at = Zara4::API::Communication::Util::calculate_expiry_time(tokens['expires_in'])
28
+
29
+ return Zara4::API::Communication::AccessToken::RefreshableAccessToken.new(@client_id, @client_secret, access_token, expires_at, refresh_token)
30
+ end
31
+
32
+
33
+ end
34
+ end
@@ -0,0 +1,37 @@
1
+ module Zara4::API::Communication
2
+ class Config
3
+
4
+ USER_AGENT = 'Zara 4 RUBY-SDK, Version-' + Zara4::API::VERSION
5
+
6
+ PRODUCTION_API_ENDPOINT = 'https://api.zara4.com'
7
+ DEVELOPMENT_API_ENDPOINT = 'http://api.zara4.dev'
8
+
9
+ @@BASE_URL = PRODUCTION_API_ENDPOINT
10
+
11
+
12
+ #
13
+ # Get the base url of the API endpoint.
14
+ #
15
+ def self.api_endpoint_url
16
+ return @@BASE_URL
17
+ end
18
+
19
+
20
+ #
21
+ # Configure production mode.
22
+ #
23
+ def self.enter_production_mode
24
+ @@BASE_URL = PRODUCTION_API_ENDPOINT
25
+ end
26
+
27
+
28
+ #
29
+ # Configure development mode.
30
+ #
31
+ def self.enter_development_mode
32
+ @@BASE_URL = DEVELOPMENT_API_ENDPOINT
33
+ end
34
+
35
+
36
+ end
37
+ end
@@ -0,0 +1,7 @@
1
+ module Zara4::API::Communication::Grant
2
+ end
3
+
4
+ require_relative './grant/grant_request.rb'
5
+ require_relative './grant/client_credentials_grant_request.rb'
6
+ require_relative './grant/password_grant.rb'
7
+ require_relative './grant/refresh_token_grant.rb'
@@ -0,0 +1,14 @@
1
+ module Zara4::API::Communication::Grant
2
+ class ClientCredentialsGrantRequest < GrantRequest
3
+
4
+
5
+ #
6
+ # The type of this grant.
7
+ #
8
+ def grant_type
9
+ return 'client_credentials'
10
+ end
11
+
12
+
13
+ end
14
+ end
@@ -0,0 +1,72 @@
1
+ module Zara4::API::Communication::Grant
2
+ class GrantRequest
3
+ include HTTParty
4
+
5
+
6
+ attr_accessor :client_id, :client_secret, :scopes
7
+
8
+
9
+ #
10
+ # Constructor
11
+ #
12
+ def initialize(client_id, client_secret, scopes)
13
+ @client_id = client_id
14
+ @client_secret = client_secret
15
+ @scopes = scopes
16
+ end
17
+
18
+
19
+ #
20
+ # Get tokens from the API
21
+ #
22
+ def get_tokens
23
+
24
+ url = Zara4::API::Communication::Util::url('/oauth/access_token')
25
+
26
+ parameters = {
27
+ 'grant_type' => grant_type(),
28
+ 'client_id' => @client_id,
29
+ 'client_secret' => @client_secret,
30
+ 'scope' => @scopes.join(','),
31
+ }
32
+
33
+ headers = {
34
+ 'Content-Type' => 'application/json'
35
+ }
36
+
37
+ response = self.class.post(url, {
38
+ body: parameters.to_json,
39
+ headers: headers
40
+ })
41
+
42
+
43
+ # Check for API error response
44
+ if response.has_key?('error')
45
+ puts 'ERROR IS ' + response.fetch('error')
46
+ end
47
+
48
+ return {
49
+ 'access_token' => response.fetch('access_token'),
50
+ 'expires_in' => response.fetch('expires_in'),
51
+ }
52
+ end
53
+
54
+
55
+ #
56
+ # Add image processing to the request scope.
57
+ #
58
+ def with_image_processing
59
+ @scopes.push('image-processing')
60
+ end
61
+
62
+
63
+ #
64
+ # Add usage to the request scope.
65
+ #
66
+ def with_usage
67
+ @scopes.push('usage')
68
+ end
69
+
70
+
71
+ end
72
+ end
@@ -0,0 +1,33 @@
1
+ module Zara4::API::Communication::Grant
2
+ class PasswordGrant < GrantRequest
3
+
4
+ attr_accessor :username, :password
5
+
6
+
7
+ def initialize(client_id, client_secret, username, password, scopes)
8
+ super(client_id, client_secret, scopes)
9
+ @username = username
10
+ @password = password
11
+ end
12
+
13
+
14
+ #
15
+ # The type of this grant.
16
+ #
17
+ def grant_type
18
+ return 'password'
19
+ end
20
+
21
+
22
+ #
23
+ # Data to be sent when fetching grant tokens.
24
+ #
25
+ def data
26
+ data = super.data
27
+ data['username'] = @username
28
+ data['password'] = @password
29
+ return data
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ module Zara4::API::Communication::Grant
2
+ class RefreshTokenGrant < GrantRequest
3
+
4
+ attr_accessor :refresh_token
5
+
6
+
7
+ def initialize(client_id, client_secret, refresh_token, scopes)
8
+ super(client_id, client_secret, scopes)
9
+ @refresh_token = refresh_token
10
+ end
11
+
12
+
13
+ #
14
+ # The type of this grant.
15
+ #
16
+ def grant_type
17
+ return 'refresh_token'
18
+ end
19
+
20
+
21
+ #
22
+ # Data to be sent when fetching grant tokens.
23
+ #
24
+ def data
25
+ data = super.data()
26
+ data['refresh_token'] = @refresh_token
27
+ end
28
+
29
+
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ module Zara4::API::Communication
2
+ class Util
3
+
4
+
5
+ #
6
+ # Get the url to the given path.
7
+ #
8
+ def self.url(path)
9
+ return Zara4::API::Communication::Config::api_endpoint_url() + path
10
+ end
11
+
12
+
13
+
14
+ def post(target_url, data)
15
+
16
+ end
17
+
18
+
19
+ #
20
+ # Calculate the expiry time from the given lifetime time.
21
+ #
22
+ def self.calculate_expiry_time(expires_in_seconds)
23
+ expires_in_seconds = expires_in_seconds - 60
24
+ return Time.now + expires_in_seconds
25
+ end
26
+
27
+
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ module Zara4::API::ImageProcessing
2
+ end
3
+
4
+ require_relative './image_processing/colour_enhancement.rb'
5
+ require_relative './image_processing/optimisation_mode.rb'
6
+ require_relative './image_processing/output_format.rb'
7
+ require_relative './image_processing/resize_mode.rb'
8
+
9
+ require_relative './image_processing/request.rb'
10
+ require_relative './image_processing/remote_image_request.rb'
11
+ require_relative './image_processing/local_image_request.rb'
12
+ require_relative './image_processing/processed_image.rb'
@@ -0,0 +1,5 @@
1
+ module Zara4::API::ImageProcessing::ColourEnhancement
2
+ NONE = 'none'
3
+ IMPROVE_COLOUR = 'improve-colour'
4
+ DINGY_ROOM = 'dingy-room'
5
+ end
@@ -0,0 +1,19 @@
1
+ module Zara4::API::ImageProcessing
2
+ class LocalImageRequest < Request
3
+
4
+
5
+ def initialize(path_to_image, optimisation_mode=nil, output_format=nil, colour_enhancement=nil, resize_mode=nil, width=100, height=100)
6
+ super(optimisation_mode, output_format, colour_enhancement, resize_mode, width, height)
7
+ @path_to_image = path_to_image
8
+ end
9
+
10
+
11
+ def generate_form_data
12
+ data = super
13
+ data['file'] = File.new(@path_to_image)
14
+ return data
15
+ end
16
+
17
+
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Zara4::API::ImageProcessing::OptimisationMode
2
+ HIGHEST = 'highest'
3
+ COMPROMISE = 'compromise'
4
+ LOWEST = 'lowest'
5
+ end
@@ -0,0 +1,5 @@
1
+ module Zara4::API::ImageProcessing::OutputFormat
2
+ MATCH = 'match'
3
+ JPEG = 'jpeg'
4
+ PNG = 'png'
5
+ end
@@ -0,0 +1,57 @@
1
+ module Zara4::API::ImageProcessing
2
+ class ProcessedImage
3
+
4
+ attr_accessor :request, :request_id, :file_urls, :original_file_size, :compressed_file_size
5
+
6
+
7
+ def initialize(request, request_id, file_urls, original_file_size, compressed_file_size)
8
+ @request = request
9
+ @request_id = request_id
10
+ @file_urls = file_urls
11
+ @original_file_size = original_file_size
12
+ @compressed_file_size = compressed_file_size
13
+ end
14
+
15
+
16
+ #
17
+ # Get the file size (in bytes) of the original uncompressed image.
18
+ #
19
+ def original_file_size
20
+ return @original_file_size
21
+ end
22
+
23
+
24
+ #
25
+ # Get the file size (in bytes) of the compressed image.
26
+ #
27
+ def compressed_file_size
28
+ return @compressed_file_size
29
+ end
30
+
31
+
32
+ #
33
+ # Get the ratio by which the image has been compressed.
34
+ #
35
+ def compression_ratio
36
+ return @compressed_file_size / @original_file_size
37
+ end
38
+
39
+
40
+ #
41
+ # The percentage compression achieved.
42
+ #
43
+ def percentage_saving
44
+ return (1 - compression_ratio()) * 100
45
+ end
46
+
47
+
48
+ #
49
+ # Was the original image compressed?
50
+ #
51
+ def compression_was_achieved
52
+ return compression_ratio() < 1
53
+ end
54
+
55
+
56
+ end
57
+ end
@@ -0,0 +1,19 @@
1
+ module Zara4::API::ImageProcessing
2
+ class RemoteImageRequest < Request
3
+
4
+
5
+ def initialize(url, optimisation_mode=nil, output_format=nil, colour_enhancement=nil, resize_mode=nil, width=100, height=100)
6
+ super(optimisation_mode, output_format, colour_enhancement, resize_mode, width, height)
7
+ @url = url
8
+ end
9
+
10
+
11
+ def generate_form_data
12
+ data = super
13
+ data['url'] = @url
14
+ return data
15
+ end
16
+
17
+
18
+ end
19
+ end
@@ -0,0 +1,63 @@
1
+ module Zara4::API::ImageProcessing
2
+ class Request
3
+
4
+ attr_accessor :optimisation_mode, :output_format, :resize_mode, :colour_enhancement, :width, :height
5
+
6
+ #
7
+ # Constructor
8
+ #
9
+ def initialize(optimisation_mode=nil, output_format=nil, colour_enhancement=nil, resize_mode=nil, width=100, height=100)
10
+
11
+ if optimisation_mode != nil
12
+ @optimisation_mode = optimisation_mode
13
+ else
14
+ @optimisation_mode = Zara4::API::ImageProcessing::OptimisationMode::COMPROMISE
15
+ end
16
+
17
+ if output_format != nil
18
+ @output_format = output_format
19
+ else
20
+ @output_format = Zara4::API::ImageProcessing::OutputFormat::MATCH
21
+ end
22
+
23
+ if colour_enhancement != nil
24
+ @colour_enhancement = colour_enhancement
25
+ else
26
+ @colour_enhancement = Zara4::API::ImageProcessing::ColourEnhancement::NONE
27
+ end
28
+
29
+ if resize_mode != nil
30
+ @resize_mode = resize_mode
31
+ else
32
+ @resize_mode = Zara4::API::ImageProcessing::ResizeMode::NONE
33
+ end
34
+
35
+ @width = width
36
+ @height = height
37
+
38
+ end
39
+
40
+
41
+ #
42
+ # Generate the form data for this request
43
+ #
44
+ def generate_form_data
45
+ data = {
46
+ 'optimisation-mode' => @optimisation_mode,
47
+ 'output-format' => @output_format,
48
+ 'colour-enhancement' => @colour_enhancement,
49
+ 'resize-mode' => @resize_mode
50
+ }
51
+
52
+ # Only include width and height if resize requested
53
+ if @resize_mode != nil && @resize_mode != Zara4::API::ImageProcessing::ResizeMode::NONE
54
+ data['width'] = @width
55
+ data['height'] = @height
56
+ end
57
+
58
+ return data
59
+ end
60
+
61
+
62
+ end
63
+ end
@@ -0,0 +1,6 @@
1
+ module Zara4::API::ImageProcessing::ResizeMode
2
+ NONE = 'none'
3
+ WEB_BUNDLE = 'web-bundle'
4
+ STRETCH = 'stretch'
5
+ CROP = 'crop'
6
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zara4
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Colin Stannard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httmultiparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.13
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.13
41
+ description: Zara 4 compresses and optimizes your images
42
+ email:
43
+ - support@zara4.com
44
+ - colin.stannard@cbsindustries.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - lib/zara4.rb
50
+ - lib/zara4/api.rb
51
+ - lib/zara4/api/client.rb
52
+ - lib/zara4/api/communication.rb
53
+ - lib/zara4/api/communication/access_token.rb
54
+ - lib/zara4/api/communication/access_token/access_token.rb
55
+ - lib/zara4/api/communication/access_token/refreshable_access_token.rb
56
+ - lib/zara4/api/communication/access_token/reissuable_access_token.rb
57
+ - lib/zara4/api/communication/authentication.rb
58
+ - lib/zara4/api/communication/authentication/application_authenticator.rb
59
+ - lib/zara4/api/communication/authentication/authenticator.rb
60
+ - lib/zara4/api/communication/authentication/user_authenticator.rb
61
+ - lib/zara4/api/communication/config.rb
62
+ - lib/zara4/api/communication/grant.rb
63
+ - lib/zara4/api/communication/grant/client_credentials_grant_request.rb
64
+ - lib/zara4/api/communication/grant/grant_request.rb
65
+ - lib/zara4/api/communication/grant/password_grant.rb
66
+ - lib/zara4/api/communication/grant/refresh_token_grant.rb
67
+ - lib/zara4/api/communication/util.rb
68
+ - lib/zara4/api/image_processing.rb
69
+ - lib/zara4/api/image_processing/colour_enhancement.rb
70
+ - lib/zara4/api/image_processing/local_image_request.rb
71
+ - lib/zara4/api/image_processing/optimisation_mode.rb
72
+ - lib/zara4/api/image_processing/output_format.rb
73
+ - lib/zara4/api/image_processing/processed_image.rb
74
+ - lib/zara4/api/image_processing/remote_image_request.rb
75
+ - lib/zara4/api/image_processing/request.rb
76
+ - lib/zara4/api/image_processing/resize_mode.rb
77
+ homepage: https://github.com/zara-4/ruby-sdk
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.9.3
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.5.1
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Ruby SDK for the Zara 4 image compression API
101
+ test_files: []