smartring 0.0.3 → 0.0.4
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/smartling/files.rb +19 -2
- data/test/smartling/files_test.rb +16 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0186db928d2b135eccb55cf0a78461d6d2de1aaf0bb12497c30f54644118368
|
4
|
+
data.tar.gz: 13e889e780917a69b032812e6e1e20f2409e7139edf3fe8523d4b22ba8eb58ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe6990b16bd45818214facf572931b5eaac4cb81e01085a8087671cb100c001d61fc89a049a4199513d838f52e4ab3808b690342fd0308cd4a067aa8f2ffd075
|
7
|
+
data.tar.gz: 473c135bb3239d230c80a9418be91f68a44a167f54d82041b300d88211fd678355739405034fe132a2c427e6962d5e291777850068002662aa6a0a41b653d6ac
|
data/lib/smartling/files.rb
CHANGED
@@ -6,9 +6,26 @@ require 'net/http/post/multipart'
|
|
6
6
|
module Smartling
|
7
7
|
# Methods for using the Smartling files API
|
8
8
|
module Files
|
9
|
-
def files(project_id: @project_id
|
9
|
+
def files(project_id: @project_id, uri_mask: nil,
|
10
|
+
last_uploaded_after: nil, last_uploaded_before: nil,
|
11
|
+
order_by: nil, file_types: nil, limit: nil, offset: nil)
|
10
12
|
path = "/files-api/v2/projects/#{project_id}/files/list"
|
11
|
-
|
13
|
+
query = {}
|
14
|
+
unless last_uploaded_before.nil?
|
15
|
+
last_uploaded_before = Time.parse(last_uploaded_before.to_s).utc.iso8601
|
16
|
+
query[:lastUploadedBefore] = last_uploaded_before
|
17
|
+
end
|
18
|
+
unless last_uploaded_after.nil?
|
19
|
+
last_uploaded_after = Time.parse(last_uploaded_after.to_s).utc.iso8601
|
20
|
+
query[:lastUploadedAfter] = last_uploaded_after
|
21
|
+
end
|
22
|
+
query[:fileTypes] = file_types unless file_types.nil?
|
23
|
+
query[:uriMask] = uri_mask unless uri_mask.nil?
|
24
|
+
query[:orderBy] = order_by unless order_by.nil?
|
25
|
+
query[:limit] = limit unless limit.nil?
|
26
|
+
query[:offset] = offset unless offset.nil?
|
27
|
+
return get(path) if query.empty?
|
28
|
+
get(path, query: query)
|
12
29
|
end
|
13
30
|
|
14
31
|
def file_types(project_id: @project_id)
|
@@ -14,8 +14,22 @@ describe Smartling::Files do
|
|
14
14
|
|
15
15
|
describe 'files' do
|
16
16
|
it 'lists files the items of the smartling files result' do
|
17
|
-
|
18
|
-
|
17
|
+
before = Time.parse('2001-01-01')
|
18
|
+
after = Time.parse('2000-01-01')
|
19
|
+
smartling.expect(:get, nil) do |path, query:|
|
20
|
+
assert_equal '/files-api/v2/projects/1/files/list', path
|
21
|
+
assert_equal before, Time.parse(query[:lastUploadedBefore])
|
22
|
+
assert_equal after, Time.parse(query[:lastUploadedAfter])
|
23
|
+
assert_equal 100, query[:limit]
|
24
|
+
assert_equal 10, query[:offset]
|
25
|
+
assert_equal 'created', query[:orderBy]
|
26
|
+
assert_equal %w(html json), query[:fileTypes]
|
27
|
+
assert_equal '.foo', query[:uriMask]
|
28
|
+
end
|
29
|
+
smartling.files(project_id: 1, last_uploaded_before: before,
|
30
|
+
last_uploaded_after: after, limit: 100, offset: 10,
|
31
|
+
order_by: 'created', file_types: %w(html json),
|
32
|
+
uri_mask: '.foo')
|
19
33
|
end
|
20
34
|
end
|
21
35
|
|