ruby-jet 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/lib/jet/client.rb +5 -0
- data/lib/jet/client/files.rb +40 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b46ee6ef36dc71fd56c9eb489c752888c9bc540b
|
4
|
+
data.tar.gz: 18b13fe4160681fc262b41e24fd770682475f334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b840ea663d3d4a78d82cc88c4db90c5a5a82cdfeba18acea43e2e454d484a01130c918342f7551d0675e9503d1935b758570bce6aad8708c3cb187b760b3a837
|
7
|
+
data.tar.gz: 3f74ddd7261045b492ab2297553a01b9c95aea4b12ba252964c287f76c012f0be69d9d7480a1d6872af63cad7506d05b42ea916cfc4c2088ab77ddd9713fa338
|
data/lib/jet/client.rb
CHANGED
@@ -41,9 +41,14 @@ class Jet::Client
|
|
41
41
|
def taxonomy
|
42
42
|
Taxonomy.new(self)
|
43
43
|
end
|
44
|
+
|
45
|
+
def files
|
46
|
+
Files.new(self)
|
47
|
+
end
|
44
48
|
end
|
45
49
|
|
46
50
|
require 'jet/client/orders'
|
47
51
|
require 'jet/client/returns'
|
48
52
|
require 'jet/client/products'
|
49
53
|
require 'jet/client/taxonomy'
|
54
|
+
require 'jet/client/files'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
require 'zlib'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
class Jet::Client::Files
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
end
|
10
|
+
|
11
|
+
def upload_token
|
12
|
+
headers = @client.token
|
13
|
+
response = RestClient.get("#{Jet::Client::API_URL}/files/uploadToken", headers)
|
14
|
+
JSON.parse(response.body) if response.code == 200
|
15
|
+
end
|
16
|
+
|
17
|
+
def file_upload(url, body)
|
18
|
+
headers = { 'x-ms-blob-type' => 'blockblob' }
|
19
|
+
io = StringIO.new
|
20
|
+
gz = Zlib::GzipWriter.new(io)
|
21
|
+
gz.write(body)
|
22
|
+
gz.close
|
23
|
+
gzipped_body = io.string
|
24
|
+
response = RestClient.put(url, gzipped_body, headers)
|
25
|
+
JSON.parse(response.body) if response.code == 200
|
26
|
+
end
|
27
|
+
|
28
|
+
def uploaded_files(url, file_type, file_name)
|
29
|
+
headers = @client.token
|
30
|
+
body = { url: url, file_type: file_type, file_name: file_name }
|
31
|
+
response = RestClient.post("#{Jet::Client::API_URL}/files/uploaded", body.to_json, headers)
|
32
|
+
JSON.parse(response.body) if response.code == 200
|
33
|
+
end
|
34
|
+
|
35
|
+
def jet_file_id(file_id)
|
36
|
+
headers = @client.token
|
37
|
+
response = RestClient.get("#{Jet::Client::API_URL}/files/#{file_id}", headers)
|
38
|
+
JSON.parse(response.body) if response.code == 200
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Wells
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- README.md
|
51
51
|
- lib/jet.rb
|
52
52
|
- lib/jet/client.rb
|
53
|
+
- lib/jet/client/files.rb
|
53
54
|
- lib/jet/client/orders.rb
|
54
55
|
- lib/jet/client/products.rb
|
55
56
|
- lib/jet/client/returns.rb
|