ubiquity-envoi 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b69bfd8c091f309758a7006121731f6f788b744c483c22011e4cb6f7365fa905
4
+ data.tar.gz: bf67605647e800b49003ddfad65da89e869ccb5d3fdd7bac65d625b3ad3b9d2c
5
+ SHA512:
6
+ metadata.gz: 7e4920ca9c11de1d71515f22b8816ec931b2c595f97dfd939c843c52a2682acf6e0e2a989f317475200ff086a53b25560cc1ec4485af11a6114258ddf5545502
7
+ data.tar.gz: a41f5f9f0e84f8d3c2797961ed33c8c3dbd9f117b689279facd5ea7a054b37753badd1042c57831a09299cbca2b1ea81fe95ee2ae3ec1c39e4fd62f334516b39
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /dev/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
@@ -0,0 +1 @@
1
+ ubiquity-envoi
@@ -0,0 +1 @@
1
+ ruby-1.8.7-head
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 1.8.7
5
+ before_install: gem install bundler -v 1.15.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at john.whitson@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'json', :platforms => :mri_18
4
+
5
+ # git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in ubiquity-envoi.gemspec
8
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 XPlatform Consulting
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Ubiquity::Envoi
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ubiquity/envoi`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ubiquity-envoi'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ubiquity-envoi
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/XPlatform-Consulting/ubiquity-envoi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Ubiquity::Envoi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ubiquity-envoi/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'ubiquity/envoi'
5
+ require 'ubiquity/envoi/api/client'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'ubiquity/envoi'
3
+ require 'ubiquity/envoi/api/client'
@@ -0,0 +1,7 @@
1
+ require 'ubiquity/envoi/version'
2
+
3
+ module Ubiquity
4
+ module Envoi
5
+
6
+ end
7
+ end
@@ -0,0 +1,291 @@
1
+ require 'logger'
2
+
3
+ require 'ubiquity/envoi/api/client/http_client'
4
+ require 'ubiquity/envoi/api/client/requests'
5
+ require 'ubiquity/envoi/api/client/paginator'
6
+
7
+ module Ubiquity
8
+ module Envoi
9
+ module API
10
+ class Client
11
+
12
+ attr_accessor :http_client, :request, :response, :logger
13
+
14
+ def initialize(args = { })
15
+ @http_client = HTTPClient.new(args)
16
+ @logger = http_client.logger
17
+ end
18
+
19
+ def process_request(request, options = nil)
20
+ @paginator = nil
21
+ @response = nil
22
+ @request = request
23
+ logger.warn { "Request is Missing Required Arguments: #{request.missing_required_arguments.inspect}" } unless request.missing_required_arguments.empty?
24
+
25
+ if ([:all, 'all'].include?(request.arguments[:_page]))
26
+ request.arguments[:_page] = 1
27
+ include_remaining_pages = true
28
+ else
29
+ include_remaining_pages = false
30
+ end
31
+
32
+ request.client = self unless request.client
33
+ options ||= request.options
34
+
35
+ return (options.fetch(:return_request, true) ? request : nil) unless options.fetch(:execute_request, true)
36
+
37
+ #@response = http_client.call_method(request.http_method, { :path => request.path, :query => request.query, :body => request.body }, options)
38
+ @response = request.execute
39
+
40
+ if request.respond_to?(:success?) && !request.success?
41
+ raise "Request failed. #{request.response.code} #{response.body}"
42
+ end
43
+
44
+ if include_remaining_pages
45
+ return paginator.include_remaining_pages
46
+ end
47
+
48
+ @response
49
+ end
50
+
51
+ def paginator
52
+ @paginator ||= Paginator.new(self, { :logger => logger }) if @response
53
+ end
54
+
55
+ def process_request_using_class(request_class, args, options = { })
56
+ @response = nil
57
+ @request = request_class.new(args, options.merge(:client => self))
58
+ process_request(@request, options)
59
+ end
60
+
61
+ # Exposes HTTP Methods
62
+ # @example http(:get, '/')
63
+ def http(method, *args)
64
+ @request = nil
65
+ @response = http_client.send(method, *args)
66
+ @request = http_client.request
67
+ @response
68
+ end
69
+
70
+ # ############################################################################################################## #
71
+ # @!group API Endpoints
72
+
73
+ def content(args = { }, options = { })
74
+ http :get, 'content'
75
+ end
76
+
77
+ def content_create(args = { }, options = { })
78
+
79
+ end
80
+
81
+ def content_details(args = { }, options = { })
82
+ http :get, "content/#{args[:id]}"
83
+ end
84
+
85
+ def content_field_details(args = { }, options = { })
86
+ http :get, "content-field/#{args[:id]}"
87
+ end
88
+
89
+ def content_fieldset_details(args = { }, options = { })
90
+ http :get, "content-fieldset/#{args[:id]}"
91
+ end
92
+
93
+ def content_type_details(args = { }, options = { })
94
+ http :get, "content-type/#{args[:id]}"
95
+ end
96
+
97
+ def content_fieldsets(args = { }, options = { })
98
+ http :get, 'content-fieldset'
99
+ end
100
+
101
+ def content_types(args = { }, options = { })
102
+ http :get, 'content-type'
103
+ end
104
+ alias :content_types_get :content_types
105
+
106
+ def file_get(args = { }, options = { })
107
+ id = args[:id]
108
+
109
+ http(:get, "file/#{id}")
110
+ end
111
+
112
+ def media_file_create(args = { }, options = { })
113
+ # _request = Requests::BaseRequest.new(
114
+ # args,
115
+ # {
116
+ # :http_path => 'media-files/media-file',
117
+ # :http_method => :post,
118
+ # :parameters => [
119
+ # { :name => :name, :required => true },
120
+ # { :name => :description },
121
+ # { :name => :file },
122
+ # { :name => :metadata },
123
+ # # { :name => 'file[path]', :aliases => [ :path ], :required => true },
124
+ # # { :name => 'file[mime]', :aliases => [ :mime, :mime_type ], :required => true },
125
+ # # { :name => 'file[size]', :aliases => [ :size ], :required => true },
126
+ # # { :name => 'file[width]', :aliases => [ :width ] }
127
+ # ]
128
+ # }.merge(options)
129
+ # )
130
+ # process_request(_request, options)
131
+ process_request_using_class(Requests::MediaFileCreate, args, options)
132
+ end
133
+
134
+ def media_file_add_file(args = { }, options = { })
135
+ process_request_using_class(Requests::MediaFileAddFile, args, options)
136
+ end
137
+ alias :media_file_file_add :media_file_add_file
138
+
139
+ def media_file_delete(args = { }, options = { })
140
+ id = args[:id]
141
+
142
+ http(:delete, "media-files/media-file/#{id}")
143
+ end
144
+
145
+ def media_file_get(args = { }, options = { })
146
+ id = args[:id] || args[:media_file_id]
147
+
148
+ http(:get, "media-files/media-file/#{id}")
149
+ end
150
+
151
+ def media_file_files_get(args = { }, options = { })
152
+ id = args[:id] || args[:media_file_id]
153
+
154
+ http(:get, "media-files/media-file/#{id}/files")
155
+ end
156
+
157
+ def media_file_secured_get(args = { }, options = { })
158
+ _request = Requests::BaseRequest.new(
159
+ args,
160
+ {
161
+ :http_path => 'media-files/media-file/#{path_arguments[:media_file_id]}/secure',
162
+ :http_method => :post,
163
+ # :body => args,
164
+ :parameters => [
165
+ { :name => :media_file_id, :aliases => [ :id ], :send_in => :path },
166
+ { :name => :email, :send_in => :body },
167
+ ]
168
+ }
169
+ )
170
+ process_request(_request, options)
171
+ end
172
+
173
+
174
+ # Transcode a Media File
175
+ #
176
+ # @param [Hash] args
177
+ # @option args [String] :media_file_id
178
+ # @option args [String] :transcoder_id
179
+ # @option args [Hash] :transcoder_args
180
+ # @see http://envoi.io/api/documentation/media-files/media-files-transcode
181
+ def media_file_transcode(args = { }, options = { })
182
+ media_file_id = args[:media_file_id]
183
+ transcoder_id = args[:transcoder_id]
184
+ transcoder_args = args[:transcoder_args] || {}
185
+
186
+ http(:post, "media-files/media-file/#{media_file_id}/action/transcode/#{transcoder_id}", transcoder_args)
187
+ end
188
+
189
+ def media_file_transcode_parameters_get(args = { }, options = { })
190
+ media_file_id = args[:media_file_id]
191
+ transcoder_id = args[:transcoder_id]
192
+
193
+ http(:get, "media-files/media-file/#{media_file_id}/action/transcode/#{transcoder_id}")
194
+ end
195
+
196
+ def media_file_transcoders_get(args = { }, options = { })
197
+ media_file_id = args[:media_file_id] || args[:id]
198
+
199
+ http(:get, "media-files/media-file/#{media_file_id}/action/transcode")
200
+ end
201
+
202
+ def media_file_update(args = { }, options = { })
203
+ process_request_using_class(Requests::MediaFileUpdate, args, options)
204
+ end
205
+
206
+ def media_files_get(args = { }, options = { })
207
+ # http(:get, 'media-files/media-file?_perPage=200')
208
+
209
+ _request = Requests::BaseRequest.new(
210
+ args,
211
+ {
212
+ :http_path => 'media-files/media-file',
213
+ :parameters => [
214
+ { :name => :_perPage, :default_value => '200' },
215
+ { :name => :_page, :default_value => '1' }
216
+ ]
217
+ }
218
+ )
219
+ process_request(_request, options)
220
+ end
221
+
222
+ def media_files_detailed_get(args = { }, options = { })
223
+ # http(:get, 'media-files/media-file-detailed?_perPage=200')
224
+
225
+ _request = Requests::BaseRequest.new(
226
+ args,
227
+ {
228
+ :http_path => 'media-files/media-file-detailed',
229
+ :parameters => [
230
+ { :name => :_perPage, :aliases => [ :perPage ], :default_value => '200' },
231
+ { :name => :_page, :alises => [ :page ], :default_value => '1' }
232
+ ]
233
+ }
234
+ )
235
+ process_request(_request, options)
236
+ end
237
+
238
+ def project_get(args = { }, options = { })
239
+ _request = Requests::BaseRequest.new(
240
+ args,
241
+ {
242
+ :http_path => 'production/project/#{path_arguments[:project_id]}',
243
+ :parameters => [
244
+ { :name => :project_id, :aliases => [ :id ], :send_in => :path }
245
+ ]
246
+ }
247
+ )
248
+
249
+ process_request(_request, options)
250
+ end
251
+
252
+ def projects_get(args = { }, options = { })
253
+ _request = Requests::BaseRequest.new(
254
+ args,
255
+ {
256
+ :http_path => 'production/project',
257
+ :parameters => [
258
+
259
+ ]
260
+ }
261
+ )
262
+
263
+ process_request(_request, options)
264
+ end
265
+
266
+ def storages_get(args = { }, options = { })
267
+ http(:get, 'media-files/storage')
268
+ end
269
+
270
+ def user_create(args = { }, options = { })
271
+
272
+ end
273
+
274
+ def who
275
+ http :get, 'who'
276
+ end
277
+
278
+ # @!endgroup API Endpoints
279
+ # ############################################################################################################## #
280
+
281
+ # Client
282
+ end
283
+
284
+ # API
285
+ end
286
+
287
+ # Envoi
288
+ end
289
+
290
+ # Ubiquity
291
+ end