smartring 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91f5539a019096679d33badec75a70fa363e4f81e3f51cee66ef8cf5b69863ec
4
- data.tar.gz: '0967632d3a9dd84bf5453038a32b898a75faf06ad67e812e774d8df4c46fb49a'
3
+ metadata.gz: f0186db928d2b135eccb55cf0a78461d6d2de1aaf0bb12497c30f54644118368
4
+ data.tar.gz: 13e889e780917a69b032812e6e1e20f2409e7139edf3fe8523d4b22ba8eb58ba
5
5
  SHA512:
6
- metadata.gz: eea04bdad4bd887734963968c8d2cda50c0306c67fa50fec85083dd098772d733a076ad1f8fab0a9f63203997aa40ff164029bf7368f7140e8a73d0e987aea5f
7
- data.tar.gz: 4d0fe2605c97a2cb83f7b0208b78d8a34a8f12ee017b254c7c9216943868a4d7546d129d9d69e0cdfbd184e1503be45914105b52d17edbb9a22cfe8131528dae
6
+ metadata.gz: fe6990b16bd45818214facf572931b5eaac4cb81e01085a8087671cb100c001d61fc89a049a4199513d838f52e4ab3808b690342fd0308cd4a067aa8f2ffd075
7
+ data.tar.gz: 473c135bb3239d230c80a9418be91f68a44a167f54d82041b300d88211fd678355739405034fe132a2c427e6962d5e291777850068002662aa6a0a41b653d6ac
@@ -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
- get(path)
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
- smartling.expect(:get, nil, ['/files-api/v2/projects/1/files/list'])
18
- smartling.files(project_id: 1)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - JJ Buckley