txtextcontrol-reportingcloud 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/txtextcontrol/reportingcloud.rb +1 -1
- data/lib/txtextcontrol/reportingcloud/account_settings.rb +2 -2
- data/lib/txtextcontrol/reportingcloud/merge_body.rb +12 -5
- data/lib/txtextcontrol/reportingcloud/merge_settings.rb +2 -2
- data/lib/txtextcontrol/reportingcloud/reportingcloud.rb +16 -14
- data/lib/txtextcontrol/reportingcloud/template.rb +1 -0
- data/lib/txtextcontrol/reportingcloud/version.rb +1 -1
- metadata +2 -4
- data/.travis.yml +0 -5
- data/.vscode/settings.json +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 412bde96793b7e9aaa7d088d4df465f920939753
|
4
|
+
data.tar.gz: 0fdbf408b933dae7ba59d9afa41a70a31c0ee4be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c100d89e33189f70b8eeda8dc5e98ffaca27e6fe0df924338fa3b20fa3c677047638f2e6da2931f0ec532af8c308396f49b35f4d96b17c01be0ca6f433247b59
|
7
|
+
data.tar.gz: b23785fe5d263f8d5f55816dfa944e48d4efa8a682679f74737f43eabfaabde9c8e47193ae7d5be483e8b7f6f2ccbb49a09b6e4c1751b9388b1bc709e73a400e
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ This is the official Ruby wrapper for ReportingCloud, which is authored, maintai
|
|
8
8
|
|
9
9
|
Before using ReportingCloud, please sign up to the service:
|
10
10
|
|
11
|
-
[
|
11
|
+
[https://portal.reporting.cloud](https://portal.reporting.cloud)
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -34,7 +34,7 @@ You can read the [API documentation](https://textcontrol.github.io/txtextcontrol
|
|
34
34
|
|
35
35
|
$ yard doc
|
36
36
|
|
37
|
-
The resultant set of HTML files will be written to `~/txtextcontrol-reportingcloud/doc`.
|
37
|
+
The resultant set of HTML files will be written to `~/txtextcontrol-reportingcloud-ruby/doc`.
|
38
38
|
|
39
39
|
If you don't have YARD already installed, you can install it with RubyGems with the following command:
|
40
40
|
|
@@ -21,7 +21,7 @@ module TXTextControl
|
|
21
21
|
module ReportingCloud
|
22
22
|
|
23
23
|
# Default API base url.
|
24
|
-
DEFAULT_BASE_URI = "
|
24
|
+
DEFAULT_BASE_URI = "https://api.reporting.cloud"
|
25
25
|
# Default API version.
|
26
26
|
DEFAULT_VERSION = "v1"
|
27
27
|
# Default http request timeout in seconds.
|
@@ -16,7 +16,7 @@ module TXTextControl
|
|
16
16
|
|
17
17
|
# Represents ReportingCloud account settings.
|
18
18
|
# @attr_reader [String, Symbol] serial_number The serial number that is attached to the
|
19
|
-
# account. Possible values are
|
19
|
+
# account. Possible values are +:free+, +:trial+ and a 13 character long serial number.
|
20
20
|
# @attr_reader [Integer] created_documents The number of created documents in the
|
21
21
|
# current month.
|
22
22
|
# @attr_reader [Integer] uploaded_templates The number of uploaded templates to the
|
@@ -37,7 +37,7 @@ module TXTextControl
|
|
37
37
|
attr_reader :valid_until
|
38
38
|
|
39
39
|
# @param [String, Symbol] serial_number The serial number that is attached to the
|
40
|
-
# account. Possible values are
|
40
|
+
# account. Possible values are +:free+, +:trial+ and a 13 character long serial number.
|
41
41
|
# @param [Integer] created_documents The number of created documents in the
|
42
42
|
# current month.
|
43
43
|
# @param [Integer] uploaded_templates The number of uploaded templates to the
|
@@ -25,7 +25,6 @@ module TXTextControl
|
|
25
25
|
# author.
|
26
26
|
# @author Thorsten Kummerow (@thomerow)
|
27
27
|
class MergeBody
|
28
|
-
attr_accessor :merge_data
|
29
28
|
attr_accessor :template
|
30
29
|
attr_accessor :merge_settings
|
31
30
|
|
@@ -37,14 +36,22 @@ module TXTextControl
|
|
37
36
|
# merge properties and document properties such as title and
|
38
37
|
# author.
|
39
38
|
def initialize(merge_data, merge_settings = nil, template = nil)
|
40
|
-
|
41
|
-
raise ArgumentError, "Merge data must be a non empty array of hashes."
|
42
|
-
end
|
43
|
-
@merge_data = merge_data
|
39
|
+
self.merge_data = merge_data
|
44
40
|
@template = template
|
45
41
|
@merge_settings = merge_settings
|
46
42
|
end
|
47
43
|
|
44
|
+
def merge_data=(val)
|
45
|
+
unless val.kind_of?(Array) && !val.empty? && val[0].kind_of?(Hash)
|
46
|
+
raise ArgumentError, "Merge data must be a non empty array of hashes."
|
47
|
+
end
|
48
|
+
@merge_data = val
|
49
|
+
end
|
50
|
+
|
51
|
+
def merge_data
|
52
|
+
@merge_data
|
53
|
+
end
|
54
|
+
|
48
55
|
# Converts a MergeBody instance to a hash while converting the attribute names
|
49
56
|
# from snake case to camel case.
|
50
57
|
# @return [Hash] A hash representing the MergeBody instance.
|
@@ -99,11 +99,11 @@ module TXTextControl
|
|
99
99
|
"removeEmptyImages" => @remove_empty_images,
|
100
100
|
"removeTrailingWhitespace" => @remove_trailing_whitespace,
|
101
101
|
"author" => @author,
|
102
|
-
"creationDate" => @creation_date.nil? ? nil : creation_date.iso8601,
|
102
|
+
"creationDate" => @creation_date.nil? ? nil : @creation_date.iso8601,
|
103
103
|
"creatorApplication" => @creator_application,
|
104
104
|
"documentSubject" => @document_subject,
|
105
105
|
"documentTitle" => @document_title,
|
106
|
-
"lastModificationDate" => @last_modification_date.nil? ? nil : last_modification_date.iso8601,
|
106
|
+
"lastModificationDate" => @last_modification_date.nil? ? nil : @last_modification_date.iso8601,
|
107
107
|
"userPassword" => @user_password
|
108
108
|
}
|
109
109
|
end
|
@@ -28,11 +28,11 @@ module TXTextControl
|
|
28
28
|
# The main wrapper class.
|
29
29
|
# @attr username [String] The user name.
|
30
30
|
# @attr password [String] The password.
|
31
|
-
# @attr base_uri [String] The API base url. Is set to "
|
31
|
+
# @attr base_uri [String] The API base url. Is set to "+https://api.reporting.cloud+"
|
32
32
|
# by default.
|
33
|
-
# @attr api_version [String] The API version. Is set to "v1" by default.
|
33
|
+
# @attr api_version [String] The API version. Is set to "+v1+" by default.
|
34
34
|
# @attr read_timeout [Integer] The timeout for HTTP requests in seconds. Is set to
|
35
|
-
# 10 by default.
|
35
|
+
# +10+ by default.
|
36
36
|
# @author Thorsten Kummerow (@thomerow)
|
37
37
|
class ReportingCloud
|
38
38
|
attr_accessor :username
|
@@ -43,7 +43,7 @@ module TXTextControl
|
|
43
43
|
|
44
44
|
# @param username [String] The user name.
|
45
45
|
# @param password [String] The password.
|
46
|
-
# @param base_url [String] The API base url. Is set to "
|
46
|
+
# @param base_url [String] The API base url. Is set to "+https://api.reporting.cloud+"
|
47
47
|
# by default.
|
48
48
|
def initialize(username, password, base_url = nil)
|
49
49
|
base_url ||= DEFAULT_BASE_URI
|
@@ -84,13 +84,14 @@ module TXTextControl
|
|
84
84
|
# Merges and returns a template from the template storage or an
|
85
85
|
# uploaded template with JSON data.
|
86
86
|
# @param return_format [Symbol] The format of the created document. Possible
|
87
|
-
# values are
|
87
|
+
# values are +:pdf+, +:rtf+, +:doc+, +:docx+, +:html+ and +:tx+.
|
88
88
|
# @param merge_body [MergeBody] The MergeBody object contains the datasource
|
89
89
|
# as a JSON data object and optionally, a template encoded as a Base64 string.
|
90
90
|
# @param template_name [String] The name of the template in the template storage.
|
91
91
|
# If no template name is specified, the template must be uploaded in the
|
92
92
|
# MergeBody object of this request.
|
93
|
-
# @param append [Boolean]
|
93
|
+
# @param append [Boolean] Specifies whether the documents should be appened
|
94
|
+
# to one resulting document when more than 1 data row is passed.
|
94
95
|
# @return [Array<String>] An array of the created documents as
|
95
96
|
# Base64 encoded strings.
|
96
97
|
def merge_document(merge_body, template_name = nil, return_format = :pdf, append = false)
|
@@ -131,12 +132,12 @@ module TXTextControl
|
|
131
132
|
|
132
133
|
# Returns a list of thumbnails of a specific template.
|
133
134
|
# @param template_name [String] The filename of the template in the template storage.
|
134
|
-
# @param zoom_factor [Integer] An Integer value between 1 and 400 to set the
|
135
|
+
# @param zoom_factor [Integer] An Integer value between +1+ and +400+ to set the
|
135
136
|
# percentage zoom factor of the created thumbnail images.
|
136
137
|
# @param from_page [Integer] An Integer value that specifies the first page.
|
137
138
|
# @param to_page [Integer] An Integer value that specifies the last page.
|
138
139
|
# @param image_format [Symbol] Defines the image format of the returned thumbnails.
|
139
|
-
# Possible values are
|
140
|
+
# Possible values are +:png+, +:jpg+, +:gif+ and +:bmp+.
|
140
141
|
# @return [Array<String>] An array of Base64 encoded images.
|
141
142
|
def get_template_thumbnails(template_name, zoom_factor, from_page = 1, to_page = 0, image_format = :png)
|
142
143
|
# Prepare query parameters
|
@@ -173,7 +174,7 @@ module TXTextControl
|
|
173
174
|
end
|
174
175
|
end
|
175
176
|
|
176
|
-
# Stores an uploaded template in the template storage (
|
177
|
+
# Stores an uploaded template in the template storage ( +*.doc+, +*.docx+, +*.rtf+ and +*.tx+)
|
177
178
|
# @param template_name [String] The filename of the template in the template storage.
|
178
179
|
# Existing files with the same filename will be overwritten.
|
179
180
|
# @param template_data [String] A document encoded as a Base64 string.
|
@@ -246,9 +247,9 @@ module TXTextControl
|
|
246
247
|
|
247
248
|
# Converts a document to another format.
|
248
249
|
# @param template_data [String] The source document encoded as a Base64 string.
|
249
|
-
# The supported document formats are
|
250
|
+
# The supported document formats are +.rtf+, +.doc+, +.docx+, +.html+, +.pdf+ and +.tx+.
|
250
251
|
# @param return_format [Symbol] The format of the created document.
|
251
|
-
# Possible values are:
|
252
|
+
# Possible values are: +:pdf+, +:rtf+, +:doc+, +:docx+, +:html+ and +:tx+.
|
252
253
|
# @return [String] The created document encoded as a Base64 string.
|
253
254
|
def convert_document(template_data, return_format = :pdf)
|
254
255
|
# Parameter validation
|
@@ -265,10 +266,10 @@ module TXTextControl
|
|
265
266
|
end
|
266
267
|
|
267
268
|
# Performs a HTTP request of a given type.
|
268
|
-
# @param request_type [Symbol] The type of the request. Possible values are
|
269
|
-
#
|
269
|
+
# @param request_type [Symbol] The type of the request. Possible values are +:get+,
|
270
|
+
# +:post+ and +:delete+.
|
270
271
|
# @param params [Hash] The query parameters.
|
271
|
-
# @param body [Object, Hash, String]
|
272
|
+
# @param body [Object, Hash, String] The request body.
|
272
273
|
# @return [Net::HTTPResponse] The HTTP response.
|
273
274
|
private
|
274
275
|
def request(request_uri, request_type = :get, params = nil, body = nil)
|
@@ -276,6 +277,7 @@ module TXTextControl
|
|
276
277
|
query_string = query_string_from_hash(params)
|
277
278
|
|
278
279
|
http = Net::HTTP.new(@base_uri.host, @base_uri.port)
|
280
|
+
http.use_ssl = @base_uri.scheme == "https"
|
279
281
|
http.read_timeout = read_timeout
|
280
282
|
|
281
283
|
# Get correct request type
|
@@ -16,6 +16,7 @@ require 'date'
|
|
16
16
|
module TXTextControl
|
17
17
|
module ReportingCloud
|
18
18
|
|
19
|
+
# Holds information about a template in the template storage.
|
19
20
|
# @attr_reader template_name [String] The template file name.
|
20
21
|
# @attr_reader modified [DateTime] The date and time the template file was
|
21
22
|
# last modified.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txtextcontrol-reportingcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thorsten Kummerow
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,8 +62,6 @@ extra_rdoc_files: []
|
|
62
62
|
files:
|
63
63
|
- ".gitignore"
|
64
64
|
- ".rspec"
|
65
|
-
- ".travis.yml"
|
66
|
-
- ".vscode/settings.json"
|
67
65
|
- Gemfile
|
68
66
|
- LICENSE.md
|
69
67
|
- README.md
|
data/.travis.yml
DELETED
data/.vscode/settings.json
DELETED