springcm-sdk 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0e776f098d469fb41d0554adcb37d29bb5dbd0392a015e115f71cd9f78763d8
4
- data.tar.gz: e2a606492c73f992a4529298f459be0e5ffc9301c1c8d0cc2e4385c77d5eab3f
3
+ metadata.gz: 22ec13117031daaf638d3833204abb76fae44fcdb442641bf3c9d58b4259cebc
4
+ data.tar.gz: 18e0531670b293bfc5d9712bd0bcbd1b63848976631fabd9bf32c117bf47cd83
5
5
  SHA512:
6
- metadata.gz: d8fff91dc985edf0cc4ec5108e7cedb5ab5d70c7ac84c8748e1809620ee91494f33b186e51ee954e68c2223d2a02a12d6ebe9437fa3c865aff273aa85ee10d83
7
- data.tar.gz: 2786f445b350f4f00370042f8074f2a6d5ab7efbbbdba297d81669b7e94824594ccb5a7a066ec5a438bf882bdf2b8f1da53589ba4bb044e63fcf556c55e2c471
6
+ metadata.gz: da566b1acdee33d54ac19ae64a3887f30201897a6774e6506721ee39c8d894e6261c17e43243b6e70a2fa4c9903f938f456a776e34b42e71a922db97190adf20
7
+ data.tar.gz: a890420ebed58f4bc1d0c0a8898a35208362742637629146a623b8d197124d92f05c3c37eb643678ef236cf21d5a30db3aba2844272f89a6e7d281695688f2a0
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to springcm-sdk will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [1.2.0] - 2020-03-20 🎂
8
+ ### Added
9
+ * Folder#copy method
10
+ * Document#copy method
11
+
7
12
  ## [1.1.0] - 2020-03-06
8
13
  ### Added
9
14
  * Document#upload_version method to check in a new version of a Document.
@@ -147,7 +152,7 @@ All notable changes to springcm-sdk will be documented in this file.
147
152
  ### Added
148
153
  * Initial release to reserve gem name
149
154
 
150
- [Unreleased]: https://github.com/paulholden2/springcm-sdk/compare/1.1.0...HEAD
155
+ [Unreleased]: https://github.com/paulholden2/springcm-sdk/compare/1.2.0...HEAD
151
156
  [0.1.0]: https://github.com/paulholden2/springcm-sdk/releases/tag/0.1.0
152
157
  [0.1.1]: https://github.com/paulholden2/springcm-sdk/releases/tag/0.1.1
153
158
  [0.1.2]: https://github.com/paulholden2/springcm-sdk/releases/tag/0.1.2
@@ -166,3 +171,4 @@ All notable changes to springcm-sdk will be documented in this file.
166
171
  [1.0.0]: https://github.com/paulholden2/springcm-sdk/releases/tag/1.0.0
167
172
  [1.0.1]: https://github.com/paulholden2/springcm-sdk/releases/tag/1.0.1
168
173
  [1.1.0]: https://github.com/paulholden2/springcm-sdk/releases/tag/1.1.0
174
+ [1.2.0]: https://github.com/paulholden2/springcm-sdk/releases/tag/1.2.0
data/lib/springcm-sdk.rb CHANGED
@@ -86,4 +86,10 @@ module Springcm
86
86
  super("The attribute field #{group}.#{field} is not repeatable. Use #field to access and modify values.")
87
87
  end
88
88
  end
89
+
90
+ class CopyTaskAwaitTimeout < Error
91
+ def initialize
92
+ super("Timed out while awaiting CopyTask to complete.")
93
+ end
94
+ end
89
95
  end
@@ -0,0 +1,27 @@
1
+ require "springcm-sdk/resource"
2
+
3
+ module Springcm
4
+ class CopyTask < Resource
5
+ def await!(interval: 1, tries: 10, backoff: 2)
6
+ while tries > 0
7
+ return true if complete?
8
+ sleep(interval)
9
+ interval *= backoff
10
+ tries -= 1
11
+ end
12
+ raise Springcm::CopyTaskAwaitTimeout.new
13
+ end
14
+
15
+ def await(interval: 1, tries: 10, backoff: 2)
16
+ begin
17
+ await!(interval: interval, tries: tries, backoff: backoff)
18
+ rescue Springcm::CopyTaskAwaitTimeout => timeout
19
+ return false
20
+ end
21
+ end
22
+
23
+ def complete?
24
+ get.status != "Processing"
25
+ end
26
+ end
27
+ end
@@ -94,6 +94,26 @@ module Springcm
94
94
  end
95
95
  end
96
96
 
97
+ def copy(path: nil, uid: nil)
98
+ parent = @client.folder(path: path, uid: uid)
99
+ body = {
100
+ "DestinationFolder" => parent.raw,
101
+ "DocumentsToCopy" => [ raw ]
102
+ }
103
+ conn = @client.authorized_connection(url: @client.object_api_url)
104
+ res = conn.post do |req|
105
+ req.headers["Content-Type"] = "application/json"
106
+ req.url "copytasks"
107
+ req.body = body.to_json
108
+ end
109
+ if res.success?
110
+ data = JSON.parse(res.body)
111
+ CopyTask.new(data, @client)
112
+ else
113
+ nil
114
+ end
115
+ end
116
+
97
117
  def delete!
98
118
  unsafe_delete
99
119
  end
@@ -2,6 +2,7 @@ require "springcm-sdk/resource"
2
2
  require "springcm-sdk/document"
3
3
  require "springcm-sdk/resource_list"
4
4
  require "springcm-sdk/change_security_task"
5
+ require "springcm-sdk/copy_task"
5
6
  require "springcm-sdk/mixins/access_level"
6
7
  require "springcm-sdk/mixins/parent_folder"
7
8
  require "springcm-sdk/mixins/documents"
@@ -136,5 +137,25 @@ module Springcm
136
137
  nil
137
138
  end
138
139
  end
140
+
141
+ def copy(path: nil, uid: nil)
142
+ parent = @client.folder(path: path, uid: uid)
143
+ body = {
144
+ "DestinationFolder" => parent.raw,
145
+ "FoldersToCopy" => [ raw ]
146
+ }
147
+ conn = @client.authorized_connection(url: @client.object_api_url)
148
+ res = conn.post do |req|
149
+ req.headers["Content-Type"] = "application/json"
150
+ req.url "copytasks"
151
+ req.body = body.to_json
152
+ end
153
+ if res.success?
154
+ data = JSON.parse(res.body)
155
+ CopyTask.new(data, @client)
156
+ else
157
+ nil
158
+ end
159
+ end
139
160
  end
140
161
  end
@@ -1,3 +1,3 @@
1
1
  module Springcm
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: springcm-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Holden
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-06 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -166,6 +166,7 @@ files:
166
166
  - lib/springcm-sdk/attribute_group.rb
167
167
  - lib/springcm-sdk/change_security_task.rb
168
168
  - lib/springcm-sdk/client.rb
169
+ - lib/springcm-sdk/copy_task.rb
169
170
  - lib/springcm-sdk/document.rb
170
171
  - lib/springcm-sdk/folder.rb
171
172
  - lib/springcm-sdk/group.rb
@@ -192,7 +193,7 @@ metadata:
192
193
  allowed_push_host: https://rubygems.org
193
194
  homepage_uri: https://github.com/paulholden2/springcm-sdk
194
195
  source_code_uri: https://github.com/paulholden2/springcm-sdk
195
- documentation_uri: https://rubydoc.info/github/paulholden2/springcm-sdk/1.1.0
196
+ documentation_uri: https://rubydoc.info/github/paulholden2/springcm-sdk/1.2.0
196
197
  changelog_uri: https://github.com/paulholden2/springcm-sdk/blob/master/CHANGELOG.md
197
198
  post_install_message:
198
199
  rdoc_options: []