shotstack 0.0.9

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.
@@ -0,0 +1,175 @@
1
+ require 'date'
2
+
3
+ module Shotstack
4
+ # Model for Transition
5
+ class Transition
6
+ attr_accessor :_in
7
+
8
+ attr_accessor :out
9
+
10
+ # Attribute mapping from ruby-style variable name to JSON key.
11
+ def self.attribute_map
12
+ {
13
+
14
+ :'_in' => :'in',
15
+
16
+ :'out' => :'out'
17
+
18
+ }
19
+ end
20
+
21
+ # Attribute type mapping.
22
+ def self.swagger_types
23
+ {
24
+ :'_in' => :'String',
25
+ :'out' => :'String'
26
+
27
+ }
28
+ end
29
+
30
+ def initialize(attributes = {})
31
+ return unless attributes.is_a?(Hash)
32
+
33
+ # convert string to symbol for hash key
34
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
35
+
36
+
37
+ if attributes[:'in']
38
+ self._in = attributes[:'in']
39
+ end
40
+
41
+ if attributes[:'out']
42
+ self.out = attributes[:'out']
43
+ end
44
+
45
+ end
46
+
47
+ # Custom attribute writer method checking allowed values (enum).
48
+ def _in=(_in)
49
+ allowed_values = ["fade", "wipeLeft", "wipeRight"]
50
+ if _in && !allowed_values.include?(_in)
51
+ fail "invalid value for '_in', must be one of #{allowed_values}"
52
+ end
53
+ @_in = _in
54
+ end
55
+
56
+ # Custom attribute writer method checking allowed values (enum).
57
+ def out=(out)
58
+ allowed_values = ["fade", "wipeLeft", "wipeRight"]
59
+ if out && !allowed_values.include?(out)
60
+ fail "invalid value for 'out', must be one of #{allowed_values}"
61
+ end
62
+ @out = out
63
+ end
64
+
65
+ # Check equality by comparing each attribute.
66
+ def ==(o)
67
+ return true if self.equal?(o)
68
+ self.class == o.class &&
69
+ _in == o._in &&
70
+ out == o.out
71
+ end
72
+
73
+ # @see the `==` method
74
+ def eql?(o)
75
+ self == o
76
+ end
77
+
78
+ # Calculate hash code according to all attributes.
79
+ def hash
80
+ [_in, out].hash
81
+ end
82
+
83
+ # build the object from hash
84
+ def build_from_hash(attributes)
85
+ return nil unless attributes.is_a?(Hash)
86
+ self.class.swagger_types.each_pair do |key, type|
87
+ if type =~ /^Array<(.*)>/i
88
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
89
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
90
+ else
91
+ #TODO show warning in debug mode
92
+ end
93
+ elsif !attributes[self.class.attribute_map[key]].nil?
94
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
95
+ else
96
+ # data not found in attributes(hash), not an issue as the data can be optional
97
+ end
98
+ end
99
+
100
+ self
101
+ end
102
+
103
+ def _deserialize(type, value)
104
+ case type.to_sym
105
+ when :DateTime
106
+ DateTime.parse(value)
107
+ when :Date
108
+ Date.parse(value)
109
+ when :String
110
+ value.to_s
111
+ when :Integer
112
+ value.to_i
113
+ when :Float
114
+ value.to_f
115
+ when :BOOLEAN
116
+ if value =~ /^(true|t|yes|y|1)$/i
117
+ true
118
+ else
119
+ false
120
+ end
121
+ when /\AArray<(?<inner_type>.+)>\z/
122
+ inner_type = Regexp.last_match[:inner_type]
123
+ value.map { |v| _deserialize(inner_type, v) }
124
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
125
+ k_type = Regexp.last_match[:k_type]
126
+ v_type = Regexp.last_match[:v_type]
127
+ {}.tap do |hash|
128
+ value.each do |k, v|
129
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
130
+ end
131
+ end
132
+ else # model
133
+ _model = Shotstack.const_get(type).new
134
+ _model.build_from_hash(value)
135
+ end
136
+ end
137
+
138
+ def to_s
139
+ to_hash.to_s
140
+ end
141
+
142
+ # to_body is an alias to to_body (backward compatibility))
143
+ def to_body
144
+ to_hash
145
+ end
146
+
147
+ # return the object in the form of hash
148
+ def to_hash
149
+ hash = {}
150
+ self.class.attribute_map.each_pair do |attr, param|
151
+ value = self.send(attr)
152
+ next if value.nil?
153
+ hash[param] = _to_hash(value)
154
+ end
155
+ hash
156
+ end
157
+
158
+ # Method to output non-array value in the form of hash
159
+ # For object, use to_hash. Otherwise, just return the value
160
+ def _to_hash(value)
161
+ if value.is_a?(Array)
162
+ value.compact.map{ |v| _to_hash(v) }
163
+ elsif value.is_a?(Hash)
164
+ {}.tap do |hash|
165
+ value.each { |k, v| hash[k] = _to_hash(v) }
166
+ end
167
+ elsif value.respond_to? :to_hash
168
+ value.to_hash
169
+ else
170
+ value
171
+ end
172
+ end
173
+
174
+ end
175
+ end
@@ -0,0 +1,216 @@
1
+ require 'date'
2
+
3
+ module Shotstack
4
+ # Model for VideoClip
5
+ class VideoClip
6
+ attr_accessor :_in
7
+
8
+ attr_accessor :options
9
+
10
+ attr_accessor :out
11
+
12
+ attr_accessor :src
13
+
14
+ attr_accessor :start
15
+
16
+ attr_accessor :transition
17
+
18
+ attr_accessor :type
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+
24
+ :'_in' => :'in',
25
+
26
+ :'options' => :'options',
27
+
28
+ :'out' => :'out',
29
+
30
+ :'src' => :'src',
31
+
32
+ :'start' => :'start',
33
+
34
+ :'transition' => :'transition',
35
+
36
+ :'type' => :'type'
37
+
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.swagger_types
43
+ {
44
+ :'_in' => :'Float',
45
+ :'options' => :'VideoClipOptions',
46
+ :'out' => :'Float',
47
+ :'src' => :'String',
48
+ :'start' => :'Float',
49
+ :'transition' => :'Transition',
50
+ :'type' => :'String'
51
+
52
+ }
53
+ end
54
+
55
+ def initialize(attributes = {})
56
+ return unless attributes.is_a?(Hash)
57
+
58
+ # convert string to symbol for hash key
59
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
60
+
61
+
62
+ if attributes[:'in']
63
+ self._in = attributes[:'in']
64
+ end
65
+
66
+ if attributes[:'options']
67
+ self.options = attributes[:'options']
68
+ end
69
+
70
+ if attributes[:'out']
71
+ self.out = attributes[:'out']
72
+ end
73
+
74
+ if attributes[:'src']
75
+ self.src = attributes[:'src']
76
+ end
77
+
78
+ if attributes[:'start']
79
+ self.start = attributes[:'start']
80
+ end
81
+
82
+ if attributes[:'transition']
83
+ self.transition = attributes[:'transition']
84
+ end
85
+
86
+ if attributes[:'type']
87
+ self.type = attributes[:'type']
88
+ end
89
+
90
+ end
91
+
92
+ # Custom attribute writer method checking allowed values (enum).
93
+ def type=(type)
94
+ allowed_values = ["video"]
95
+ if type && !allowed_values.include?(type)
96
+ fail "invalid value for 'type', must be one of #{allowed_values}"
97
+ end
98
+ @type = type
99
+ end
100
+
101
+ # Check equality by comparing each attribute.
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ _in == o._in &&
106
+ options == o.options &&
107
+ out == o.out &&
108
+ src == o.src &&
109
+ start == o.start &&
110
+ transition == o.transition &&
111
+ type == o.type
112
+ end
113
+
114
+ # @see the `==` method
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculate hash code according to all attributes.
120
+ def hash
121
+ [_in, options, out, src, start, transition, type].hash
122
+ end
123
+
124
+ # build the object from hash
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ self.class.swagger_types.each_pair do |key, type|
128
+ if type =~ /^Array<(.*)>/i
129
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
130
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
131
+ else
132
+ #TODO show warning in debug mode
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ else
137
+ # data not found in attributes(hash), not an issue as the data can be optional
138
+ end
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ def _deserialize(type, value)
145
+ case type.to_sym
146
+ when :DateTime
147
+ DateTime.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value.to_s
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :BOOLEAN
157
+ if value =~ /^(true|t|yes|y|1)$/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when /\AArray<(?<inner_type>.+)>\z/
163
+ inner_type = Regexp.last_match[:inner_type]
164
+ value.map { |v| _deserialize(inner_type, v) }
165
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
166
+ k_type = Regexp.last_match[:k_type]
167
+ v_type = Regexp.last_match[:v_type]
168
+ {}.tap do |hash|
169
+ value.each do |k, v|
170
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
+ end
172
+ end
173
+ else # model
174
+ _model = Shotstack.const_get(type).new
175
+ _model.build_from_hash(value)
176
+ end
177
+ end
178
+
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_body (backward compatibility))
184
+ def to_body
185
+ to_hash
186
+ end
187
+
188
+ # return the object in the form of hash
189
+ def to_hash
190
+ hash = {}
191
+ self.class.attribute_map.each_pair do |attr, param|
192
+ value = self.send(attr)
193
+ next if value.nil?
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Method to output non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map{ |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to? :to_hash
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+
215
+ end
216
+ end
@@ -0,0 +1,185 @@
1
+ require 'date'
2
+
3
+ module Shotstack
4
+ # Model for VideoClipOptions
5
+ class VideoClipOptions
6
+ attr_accessor :effect
7
+
8
+ attr_accessor :filter
9
+
10
+ attr_accessor :volume
11
+
12
+ # Attribute mapping from ruby-style variable name to JSON key.
13
+ def self.attribute_map
14
+ {
15
+
16
+ :'effect' => :'effect',
17
+
18
+ :'filter' => :'filter',
19
+
20
+ :'volume' => :'volume'
21
+
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.swagger_types
27
+ {
28
+ :'effect' => :'String',
29
+ :'filter' => :'String',
30
+ :'volume' => :'Float'
31
+
32
+ }
33
+ end
34
+
35
+ def initialize(attributes = {})
36
+ return unless attributes.is_a?(Hash)
37
+
38
+ # convert string to symbol for hash key
39
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
40
+
41
+
42
+ if attributes[:'effect']
43
+ self.effect = attributes[:'effect']
44
+ end
45
+
46
+ if attributes[:'filter']
47
+ self.filter = attributes[:'filter']
48
+ end
49
+
50
+ if attributes[:'volume']
51
+ self.volume = attributes[:'volume']
52
+ end
53
+
54
+ end
55
+
56
+ # Custom attribute writer method checking allowed values (enum).
57
+ def effect=(effect)
58
+ allowed_values = ["zoomIn", "zoomOut", "slideLeft", "slideRight", "slideUp", "slideDown"]
59
+ if effect && !allowed_values.include?(effect)
60
+ fail "invalid value for 'effect', must be one of #{allowed_values}"
61
+ end
62
+ @effect = effect
63
+ end
64
+
65
+ # Custom attribute writer method checking allowed values (enum).
66
+ def filter=(filter)
67
+ allowed_values = ["boost", "contrast", "darken", "greyscale", "lighten", "muted", "negative"]
68
+ if filter && !allowed_values.include?(filter)
69
+ fail "invalid value for 'filter', must be one of #{allowed_values}"
70
+ end
71
+ @filter = filter
72
+ end
73
+
74
+ # Check equality by comparing each attribute.
75
+ def ==(o)
76
+ return true if self.equal?(o)
77
+ self.class == o.class &&
78
+ effect == o.effect &&
79
+ filter == o.filter &&
80
+ volume == o.volume
81
+ end
82
+
83
+ # @see the `==` method
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculate hash code according to all attributes.
89
+ def hash
90
+ [effect, filter, volume].hash
91
+ end
92
+
93
+ # build the object from hash
94
+ def build_from_hash(attributes)
95
+ return nil unless attributes.is_a?(Hash)
96
+ self.class.swagger_types.each_pair do |key, type|
97
+ if type =~ /^Array<(.*)>/i
98
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
99
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
100
+ else
101
+ #TODO show warning in debug mode
102
+ end
103
+ elsif !attributes[self.class.attribute_map[key]].nil?
104
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
105
+ else
106
+ # data not found in attributes(hash), not an issue as the data can be optional
107
+ end
108
+ end
109
+
110
+ self
111
+ end
112
+
113
+ def _deserialize(type, value)
114
+ case type.to_sym
115
+ when :DateTime
116
+ DateTime.parse(value)
117
+ when :Date
118
+ Date.parse(value)
119
+ when :String
120
+ value.to_s
121
+ when :Integer
122
+ value.to_i
123
+ when :Float
124
+ value.to_f
125
+ when :BOOLEAN
126
+ if value =~ /^(true|t|yes|y|1)$/i
127
+ true
128
+ else
129
+ false
130
+ end
131
+ when /\AArray<(?<inner_type>.+)>\z/
132
+ inner_type = Regexp.last_match[:inner_type]
133
+ value.map { |v| _deserialize(inner_type, v) }
134
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
135
+ k_type = Regexp.last_match[:k_type]
136
+ v_type = Regexp.last_match[:v_type]
137
+ {}.tap do |hash|
138
+ value.each do |k, v|
139
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
140
+ end
141
+ end
142
+ else # model
143
+ _model = Shotstack.const_get(type).new
144
+ _model.build_from_hash(value)
145
+ end
146
+ end
147
+
148
+ def to_s
149
+ to_hash.to_s
150
+ end
151
+
152
+ # to_body is an alias to to_body (backward compatibility))
153
+ def to_body
154
+ to_hash
155
+ end
156
+
157
+ # return the object in the form of hash
158
+ def to_hash
159
+ hash = {}
160
+ self.class.attribute_map.each_pair do |attr, param|
161
+ value = self.send(attr)
162
+ next if value.nil?
163
+ hash[param] = _to_hash(value)
164
+ end
165
+ hash
166
+ end
167
+
168
+ # Method to output non-array value in the form of hash
169
+ # For object, use to_hash. Otherwise, just return the value
170
+ def _to_hash(value)
171
+ if value.is_a?(Array)
172
+ value.compact.map{ |v| _to_hash(v) }
173
+ elsif value.is_a?(Hash)
174
+ {}.tap do |hash|
175
+ value.each { |k, v| hash[k] = _to_hash(v) }
176
+ end
177
+ elsif value.respond_to? :to_hash
178
+ value.to_hash
179
+ else
180
+ value
181
+ end
182
+ end
183
+
184
+ end
185
+ end
@@ -0,0 +1,3 @@
1
+ module Shotstack
2
+ VERSION = "0.0.9"
3
+ end
data/lib/shotstack.rb ADDED
@@ -0,0 +1,45 @@
1
+ # Common files
2
+ require 'shotstack/api_client'
3
+ require 'shotstack/api_error'
4
+ require 'shotstack/version'
5
+ require 'shotstack/configuration'
6
+
7
+ # Models
8
+ require 'shotstack/models/render_response_data'
9
+ require 'shotstack/models/render_response'
10
+ require 'shotstack/models/queued_response_data'
11
+ require 'shotstack/models/queued_response'
12
+ require 'shotstack/models/output'
13
+ require 'shotstack/models/transition'
14
+ require 'shotstack/models/video_clip_options'
15
+ require 'shotstack/models/video_clip'
16
+ require 'shotstack/models/image_clip_options'
17
+ require 'shotstack/models/image_clip'
18
+ require 'shotstack/models/title_clip_options'
19
+ require 'shotstack/models/title_clip'
20
+ require 'shotstack/models/track'
21
+ require 'shotstack/models/clips'
22
+ require 'shotstack/models/soundtrack'
23
+ require 'shotstack/models/timeline'
24
+ require 'shotstack/models/edit'
25
+
26
+ # APIs
27
+ require 'shotstack/api/render_api'
28
+
29
+ module Shotstack
30
+ class << self
31
+ # Customize default settings for the SDK using block.
32
+ # Shotstack.configure do |config|
33
+ # config.username = "xxx"
34
+ # config.password = "xxx"
35
+ # end
36
+ # If no block given, return the default Configuration object.
37
+ def configure
38
+ if block_given?
39
+ yield(Configuration.default)
40
+ else
41
+ Configuration.default
42
+ end
43
+ end
44
+ end
45
+ end
data/shotstack.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "shotstack/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "shotstack"
7
+ s.version = Shotstack::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = [""]
10
+ s.email = [""]
11
+ s.homepage = ""
12
+ s.summary = ""
13
+ s.description = ""
14
+ s.license = ""
15
+
16
+
17
+ s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1'
18
+ s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6'
19
+
20
+ s.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
21
+ s.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3'
22
+ s.add_development_dependency 'webmock', '~> 1.6', '>= 1.6.2'
23
+ s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
24
+ s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
25
+ s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
26
+ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.11'
27
+
28
+ s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
29
+ s.test_files = `find spec/*`.split("\n")
30
+ s.executables = []
31
+ s.require_paths = ["lib"]
32
+ end