samba_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.byebug_history +93 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/samba_api.rb +9 -0
- data/lib/samba_api/samba.rb +51 -0
- data/lib/samba_api/version.rb +3 -0
- data/samba_api.gemspec +39 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 198428da5c0b11b5a758fd11ca9b85145010d920
|
4
|
+
data.tar.gz: 339fb6f03b358b5ddeca0aa527a4a63ed750acee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dd06fb53a184b9aba02198ce810d016519e04f8fcf0215ec05cf7dba94782abc3be643af017e575e62b0c8451bb150bf0e5bfdf8674487846eadfcad2ffc4f9e
|
7
|
+
data.tar.gz: 67ca913311dc9573520c8f1ff8ddd4944afbdaf1b211c385e43ded17e0402d7191f471fa1bf19f119890ac0f835676d71e808689def7788f213c7d2d65a88cf6
|
data/.byebug_history
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
exit
|
2
|
+
response["uploadUrl"]
|
3
|
+
response
|
4
|
+
exit
|
5
|
+
response = JSON.parse(response.body)
|
6
|
+
response = JSON.parse(response)
|
7
|
+
response
|
8
|
+
exit
|
9
|
+
xi
|
10
|
+
exit
|
11
|
+
response.size
|
12
|
+
response = JSON.parse(response.body)
|
13
|
+
response.body
|
14
|
+
response
|
15
|
+
exit
|
16
|
+
response
|
17
|
+
response[:id]
|
18
|
+
response.map(&:id)
|
19
|
+
response.first.map()
|
20
|
+
response.first.map(&:id)
|
21
|
+
response.first
|
22
|
+
response.each { |r| r.map(&:id) }
|
23
|
+
response.first
|
24
|
+
response.map().map()
|
25
|
+
response.map().map(&:id)
|
26
|
+
response.map(&:id)
|
27
|
+
response.map(&:[id])
|
28
|
+
response.map(&:id)
|
29
|
+
response.size
|
30
|
+
response
|
31
|
+
response.map(&:id)
|
32
|
+
response.first["id"]
|
33
|
+
response.first
|
34
|
+
response
|
35
|
+
response = JSON.parse(response.body)
|
36
|
+
JSON.parse(response.body)
|
37
|
+
response.body
|
38
|
+
response.body.size
|
39
|
+
response.body
|
40
|
+
response.code
|
41
|
+
response.status
|
42
|
+
response
|
43
|
+
exit
|
44
|
+
response
|
45
|
+
exit
|
46
|
+
response.server_error?
|
47
|
+
response.code
|
48
|
+
response.parsed_response
|
49
|
+
response.request
|
50
|
+
response.non_authoritative_information?
|
51
|
+
response.methods
|
52
|
+
params
|
53
|
+
response
|
54
|
+
exit
|
55
|
+
HTTParty.get(endpoint_projects, access_token: 'af4bdfdf-781a-4846-b75e-8bf024586f9b')
|
56
|
+
HTTParty.get(endpoint_projects, 'af4bdfdf-781a-4846-b75e-8bf024586f9b')
|
57
|
+
exit
|
58
|
+
response
|
59
|
+
exit
|
60
|
+
response
|
61
|
+
continue
|
62
|
+
endpoint_projects
|
63
|
+
response
|
64
|
+
exit
|
65
|
+
response
|
66
|
+
continue
|
67
|
+
@options
|
68
|
+
response
|
69
|
+
continue
|
70
|
+
next
|
71
|
+
@options
|
72
|
+
exit
|
73
|
+
response
|
74
|
+
exit
|
75
|
+
response
|
76
|
+
exit
|
77
|
+
response
|
78
|
+
exit
|
79
|
+
exigt
|
80
|
+
@options["access_token"]
|
81
|
+
@options[:access_token]
|
82
|
+
@options
|
83
|
+
exit
|
84
|
+
self.class
|
85
|
+
endpoint_projects
|
86
|
+
exit
|
87
|
+
response
|
88
|
+
exit
|
89
|
+
endpoint_projects
|
90
|
+
response
|
91
|
+
exit
|
92
|
+
response.headers
|
93
|
+
response.body
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# SambaApi
|
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/samba_api`. 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 'samba_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install samba_api
|
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. 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/chiligumdev/samba_api.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "samba_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/samba_api.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'open3'
|
2
|
+
class Samba
|
3
|
+
include HTTParty
|
4
|
+
BASE_API_URL = 'https://api.sambavideos.sambatech.com/v1'
|
5
|
+
|
6
|
+
def initialize(attributes)
|
7
|
+
@options = { 'access_token' => attributes[:access_token], 'Content-Type' => 'application/json' }
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_projects
|
11
|
+
endpoint_projects = Samba::BASE_API_URL+"/projects?access_token=#{@options["access_token"]}"
|
12
|
+
response = self.class.get(endpoint_projects)
|
13
|
+
response = JSON.parse(response.body)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_project(project_id)
|
17
|
+
endpoint_project = Samba::BASE_API_URL+"/projects/#{project_id}?access_token=#{@options["access_token"]}"
|
18
|
+
response = self.class.get(endpoint_project)
|
19
|
+
response = JSON.parse(response.body)
|
20
|
+
end
|
21
|
+
|
22
|
+
def media_upload_data
|
23
|
+
body = '{ "qualifier": "VIDEO" }'
|
24
|
+
#TODO better way to get project
|
25
|
+
project_id = get_projects.first["id"]
|
26
|
+
url = Samba::BASE_API_URL+"/medias?access_token=#{@options["access_token"]}&pid=#{project_id}"
|
27
|
+
response = self.class.post(url, headers: @options, body: body)
|
28
|
+
response = JSON.parse(response.body)
|
29
|
+
end
|
30
|
+
|
31
|
+
def upload_media(video_path)
|
32
|
+
upload_url = media_upload_data["uploadUrl"]
|
33
|
+
stdin, stdout, stderr, wait_thr = *Open3.popen3(
|
34
|
+
'curl', '--silent', '--show-error',
|
35
|
+
'-X', 'POST', upload_url,
|
36
|
+
'--header', 'Content-Type: multipart/form-data',
|
37
|
+
'-F', "file=@#{video_path}"
|
38
|
+
)
|
39
|
+
wait_thr.join
|
40
|
+
return false unless stderr.eof?
|
41
|
+
return stdout.read
|
42
|
+
end
|
43
|
+
|
44
|
+
def active_media(media_id, body)
|
45
|
+
project_id = get_projects.first["id"]
|
46
|
+
url = Samba::BASE_API_URL+"/medias/#{media_id}?access_token=#{@options["access_token"]}&pid=#{project_id}"
|
47
|
+
response = self.class.put(url, headers: @options, body: body)
|
48
|
+
response = JSON.parse(response.body)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/samba_api.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'samba_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "samba_api"
|
8
|
+
spec.version = SambaApi::VERSION
|
9
|
+
spec.authors = ["Leandro"]
|
10
|
+
spec.email = ["lndr.figueredo@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Samba Videos API}
|
13
|
+
spec.description = %q{Easy way to integrate your app with samba videos api}
|
14
|
+
spec.homepage = "http://docs.sambavideos.sambatech.com"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "minitest"
|
35
|
+
spec.add_dependency "httparty"
|
36
|
+
spec.add_dependency "json"
|
37
|
+
spec.add_dependency "byebug"
|
38
|
+
end
|
39
|
+
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: samba_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leandro
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Easy way to integrate your app with samba videos api
|
98
|
+
email:
|
99
|
+
- lndr.figueredo@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".byebug_history"
|
105
|
+
- ".gitignore"
|
106
|
+
- Gemfile
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- bin/console
|
110
|
+
- bin/setup
|
111
|
+
- lib/samba_api.rb
|
112
|
+
- lib/samba_api/samba.rb
|
113
|
+
- lib/samba_api/version.rb
|
114
|
+
- samba_api.gemspec
|
115
|
+
homepage: http://docs.sambavideos.sambatech.com
|
116
|
+
licenses: []
|
117
|
+
metadata:
|
118
|
+
allowed_push_host: https://rubygems.org
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.4.8
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Samba Videos API
|
139
|
+
test_files: []
|