txtextcontrol-reportingcloud 1.1.1 → 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
  SHA1:
3
- metadata.gz: d2b985e985d074bac7f609544b426343b0be9de7
4
- data.tar.gz: 8f190bc99f4f3954f2aac8cc35a5e3e6c9bb41bc
3
+ metadata.gz: aff3d3e70f0d6163c80313a1836156fe966fe143
4
+ data.tar.gz: a2619ec7ef9f612f54665615e7e685a54703c793
5
5
  SHA512:
6
- metadata.gz: e58da2cb52df4dc3f58fb66f51466c626f6119b7609e193877eef9ed804c516fbc890743e483ab288b524e95f065128bb11dfae2aed89b41ef7743819cb5bc37
7
- data.tar.gz: e7b306757c6c86f695e82257d5e2d7ce4b53768d5e18a1cf25ef7fcf302f38882f6eca20f9cb25a877fdae21291aea01720e0143d5accf29d1c78afe9490736a
6
+ metadata.gz: 655e195d639b4e3fa872e7c73511894338e82217d1a95d47ed35dc8ef646aa9eb5d3308bde1b9cb32cbb9d9a3f1af5a76c7d6bc130351a4bb8362fa0ded90d7a
7
+ data.tar.gz: fc4b1950cd42f817288864f1a98cdee31bd2ec6108f476a86cb1b41b659677d968137c7c2d35442377d18e2505ef8c27f3630f0d687d3f1d9663cc5230542f3d
@@ -0,0 +1,61 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Debug Local File",
6
+ "type": "Ruby",
7
+ "request": "launch",
8
+ "cwd": "${workspaceRoot}",
9
+ "program": "${workspaceRoot}/main.rb"
10
+ },
11
+ {
12
+ "name": "Listen for rdebug-ide",
13
+ "type": "Ruby",
14
+ "request": "attach",
15
+ "cwd": "${workspaceRoot}",
16
+ "remoteHost": "127.0.0.1",
17
+ "remotePort": "1234",
18
+ "remoteWorkspaceRoot": "${workspaceRoot}"
19
+ },
20
+ {
21
+ "name": "Rails server",
22
+ "type": "Ruby",
23
+ "request": "launch",
24
+ "cwd": "${workspaceRoot}",
25
+ "program": "${workspaceRoot}/bin/rails",
26
+ "args": [
27
+ "server"
28
+ ]
29
+ },
30
+ {
31
+ "name": "RSpec - all",
32
+ "type": "Ruby",
33
+ "request": "launch",
34
+ "cwd": "${workspaceRoot}",
35
+ "program": "${workspaceRoot}/bin/rspec",
36
+ "args": [
37
+ "-I",
38
+ "${workspaceRoot}"
39
+ ]
40
+ },
41
+ {
42
+ "name": "RSpec - active spec file only",
43
+ "type": "Ruby",
44
+ "request": "launch",
45
+ "cwd": "${workspaceRoot}",
46
+ "program": "${workspaceRoot}/bin/rspec",
47
+ "args": [
48
+ "-I",
49
+ "${workspaceRoot}",
50
+ "${file}"
51
+ ]
52
+ },
53
+ {
54
+ "name": "Cucumber",
55
+ "type": "Ruby",
56
+ "request": "launch",
57
+ "cwd": "${workspaceRoot}",
58
+ "program": "${workspaceRoot}/bin/cucumber"
59
+ }
60
+ ]
61
+ }
@@ -0,0 +1,4 @@
1
+ // Place your settings in this file to overwrite default and user settings.
2
+ {
3
+ "editor.tabSize": 2
4
+ }
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- ## Copyright © 2017, Text Control GmbH. All rights reserved.
1
+ ## Copyright © 2019, Text Control GmbH. All rights reserved.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
4
  following conditions are met:
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  # ReportingCloud Ruby Wrapper
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/txtextcontrol-reportingcloud.svg)](https://badge.fury.io/rb/txtextcontrol-reportingcloud)
6
+
5
7
  This is the official Ruby wrapper for ReportingCloud, which is authored, maintained and fully supported by [Text Control](http://www.textcontrol.com).
6
8
 
7
9
  [http://www.reporting.cloud](http://www.reporting.cloud)
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  # Extensions to class String.
15
15
  # @author Thorsten Kummerow (@thomerow)
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  require "txtextcontrol/reportingcloud/version"
15
15
  require_relative "./reportingcloud/reportingcloud.rb"
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  module TXTextControl
15
15
  module ReportingCloud
@@ -0,0 +1,44 @@
1
+ # ReportingCloud Ruby Wrapper
2
+ #
3
+ # Official wrapper (authored by Text Control GmbH, publisher of ReportingCloud) to access
4
+ # ReportingCloud in Ruby.
5
+ #
6
+ # Go to http://www.reporting.cloud to learn more about ReportingCloud
7
+ # Go to https://github.com/TextControl/txtextcontrol-reportingcloud-ruby for the
8
+ # canonical source repository.
9
+ #
10
+ # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
+ #
12
+ # Copyright: © 2019 Text Control GmbH
13
+
14
+ module TXTextControl
15
+ module ReportingCloud
16
+
17
+ # Represents a ReportingCloud API key object.
18
+ # @attr key [String] The actual API Key that belongs to the account.
19
+ # @attr is_active [Boolean] Specifies whether the API Key is active or not (not used yet).
20
+ # @author Thorsten Kummerow (@thomerow)
21
+ class APIKey
22
+ attr_reader :is_active
23
+
24
+ # @param key [String] The actual API Key that belongs to the account.
25
+ # @param is_active [Boolean] Specifies whether the API Key is active or not (not used yet).
26
+ def initialize(key, is_active = true)
27
+ self.key = key
28
+ @is_active = is_active
29
+ end
30
+
31
+ def key
32
+ @key
33
+ end
34
+
35
+ def key=(val)
36
+ unless val.nil? || ((val.kind_of? String) && !val.to_s.empty?)
37
+ raise ArgumentError, "API key must be a non empty string."
38
+ end
39
+ @key = val
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,70 @@
1
+ # ReportingCloud Ruby Wrapper
2
+ #
3
+ # Official wrapper (authored by Text Control GmbH, publisher of ReportingCloud) to access
4
+ # ReportingCloud in Ruby.
5
+ #
6
+ # Go to http://www.reporting.cloud to learn more about ReportingCloud
7
+ # Go to https://github.com/TextControl/txtextcontrol-reportingcloud-ruby for the
8
+ # canonical source repository.
9
+ #
10
+ # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
+ #
12
+ # Copyright: © 2019 Text Control GmbH
13
+
14
+ require "txtextcontrol/reportingcloud/append_document"
15
+ require "txtextcontrol/reportingcloud/document_settings"
16
+
17
+ module TXTextControl
18
+ module ReportingCloud
19
+
20
+ # Passes data to the {ReportingCloud.append_documents} method.
21
+ # @attr documents [Array<AppendDocument>] The documents that are appended.
22
+ # @attr document_settings [DocumentSettings] Optional. Document settings to specify
23
+ # document properties such as title and author.
24
+ # @author Thorsten Kummerow (@thomerow)
25
+ class AppendBody
26
+
27
+ def initialize(documents, document_settings = nil)
28
+ self.documents = documents
29
+ self.document_settings = document_settings
30
+ end
31
+
32
+ def documents
33
+ @documents
34
+ end
35
+
36
+ def documents=(val)
37
+ unless val.kind_of?(Array)
38
+ raise ArgumentError, "Not an qarray."
39
+ end
40
+ val.each do |elem|
41
+ unless elem.is_a?(TXTextControl::ReportingCloud::AppendDocument)
42
+ raise ArgumentError, "Only elements of type \"AppendDocument\" are allowed."
43
+ end
44
+ end
45
+ @documents = val
46
+ end
47
+
48
+ def document_settings
49
+ @document_settings
50
+ end
51
+
52
+ def document_settings=(val)
53
+ unless val.is_a?(TXTextControl::ReportingCloud::DocumentSettings)
54
+ raise ArgumentError, "Must be a DocumentSettings instance."
55
+ end
56
+ @document_settings = val;
57
+ end
58
+
59
+ # Converts an AppendBody instance to a hash while converting the attribute names
60
+ # from snake case to camel case.
61
+ # @return [Hash] A hash representing the AppendBody instance.
62
+ def to_camelized_hash
63
+ return {
64
+ "documents" => @documents.map { |d| d.to_camelized_hash },
65
+ "documentSettings" => @document_settings.nil? ? nil : @document_settings.to_camelized_hash
66
+ }
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,61 @@
1
+ # ReportingCloud Ruby Wrapper
2
+ #
3
+ # Official wrapper (authored by Text Control GmbH, publisher of ReportingCloud) to access
4
+ # ReportingCloud in Ruby.
5
+ #
6
+ # Go to http://www.reporting.cloud to learn more about ReportingCloud
7
+ # Go to https://github.com/TextControl/txtextcontrol-reportingcloud-ruby for the
8
+ # canonical source repository.
9
+ #
10
+ # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
+ #
12
+ # Copyright: © 2019 Text Control GmbH
13
+
14
+ module TXTextControl
15
+ module ReportingCloud
16
+
17
+ # Passes data to the {ReportingCloud.append_documents} method.
18
+ # @attr document [String] The document as a Base64 encoded string.
19
+ # @attr document_divider [Symbol] The document divider option. Possible values are
20
+ # +:none+, +:new_paragraph+ and +:new_section+.
21
+ # @author Thorsten Kummerow (@thomerow)
22
+ class AppendDocument
23
+ attr_accessor :document_divider
24
+
25
+ def initialize(document, document_divider = :none)
26
+ self.document = document
27
+ @document_divider = document_divider
28
+ end
29
+
30
+ def document
31
+ @document
32
+ end
33
+
34
+ def document=(val)
35
+ unless val.is_a?(String)
36
+ raise ArgumentError, "document must be a Base64 encoded string."
37
+ end
38
+ @document = val
39
+ end
40
+
41
+ # Converts an AppendBody instance to a hash while converting the attribute names
42
+ # from snake case to camel case.
43
+ # @return [Hash] A hash representing the AppendBody instance.
44
+ def to_camelized_hash
45
+ result = {
46
+ "document" => @document,
47
+ "documentDivider" => "None"
48
+ }
49
+
50
+ case @document_divider
51
+ when :new_paragraph
52
+ result["documentDivider"] = "NewParagraph"
53
+ when :new_section
54
+ result["documentDivider"] = "NewSection"
55
+ end
56
+
57
+ return result
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,93 @@
1
+ # ReportingCloud Ruby Wrapper
2
+ #
3
+ # Official wrapper (authored by Text Control GmbH, publisher of ReportingCloud) to access
4
+ # ReportingCloud in Ruby.
5
+ #
6
+ # Go to http://www.reporting.cloud to learn more about ReportingCloud
7
+ # Go to https://github.com/TextControl/txtextcontrol-reportingcloud-ruby for the
8
+ # canonical source repository.
9
+ #
10
+ # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
+ #
12
+ # Copyright: © 2019 Text Control GmbH
13
+
14
+ module TXTextControl
15
+ module ReportingCloud
16
+
17
+ # Holds the merge settings needed by the {ReportingCloud.append_documents}
18
+ # method.
19
+ # @attr author [String] The document's author.
20
+ # @attr creation_date [DateTime] The document's creation date.
21
+ # @attr creator_application [String] The application which created the document.
22
+ # @attr document_subject [String] The document's subject.
23
+ # @attr document_title [String] The document's title.
24
+ # @attr last_modification_date [DateTime] The document's last modification date.
25
+ # @attr user_password [String] The password needed to open the document.
26
+ # @author Thorsten Kummerow (@thomerow)
27
+ class DocumentSettings
28
+ attr_accessor :author
29
+ attr_accessor :creator_application
30
+ attr_accessor :document_subject
31
+ attr_accessor :document_title
32
+ attr_accessor :user_password
33
+
34
+ def initialize
35
+ @author = nil
36
+ @creation_date = nil
37
+ @creator_application = nil
38
+ @document_subject = nil
39
+ @document_title = nil
40
+ @last_modification_date = nil
41
+ @user_password = nil
42
+ end
43
+
44
+ def creation_date
45
+ @creation_date
46
+ end
47
+
48
+ def creation_date=(val)
49
+ case val
50
+ when nil
51
+ @creation_date = nil
52
+ when String
53
+ @creation_date = DateTime.iso8601(val)
54
+ when DateTime
55
+ @creation_date = val
56
+ else raise ArgumentError, "Value must be a string or an instance of type DateTime."
57
+ end
58
+ end
59
+
60
+ def last_modification_date
61
+ @last_modification_date
62
+ end
63
+
64
+ def last_modification_date=(val)
65
+ case val
66
+ when nil
67
+ @last_modification_date = nil
68
+ when String
69
+ @last_modification_date = DateTime.iso8601(val)
70
+ when DateTime
71
+ @last_modification_date = val
72
+ else raise ArgumentError, "Value must be a string or an instance of type DateTime."
73
+ end
74
+ end
75
+
76
+ # Converts a DocumentSettings instance to a hash while converting the attribute names
77
+ # from snake case to camel case.
78
+ # @return [Hash] A hash representing the DocumentSettings instance.
79
+ def to_camelized_hash
80
+ return {
81
+ "author" => @author,
82
+ "creationDate" => @creation_date.nil? ? nil : @creation_date.iso8601,
83
+ "creatorApplication" => @creator_application,
84
+ "documentSubject" => @document_subject,
85
+ "documentTitle" => @document_title,
86
+ "lastModificationDate" => @last_modification_date.nil? ? nil : @last_modification_date.iso8601,
87
+ "userPassword" => @user_password
88
+ }
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  require "txtextcontrol/reportingcloud/merge_settings"
15
15
 
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  module TXTextControl
15
15
  module ReportingCloud
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  require 'txtextcontrol/reportingcloud/merge_field'
15
15
 
@@ -9,14 +9,14 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  require "txtextcontrol/reportingcloud/merge_settings"
15
15
 
16
16
  module TXTextControl
17
17
  module ReportingCloud
18
18
 
19
- # Used to pass data to the merge method.
19
+ # Passes data to the {ReportingCloud.merge_document} method.
20
20
  # @attr merge_data [Array<Hash>] The merge data. Must be an array of hashes.
21
21
  # @attr template [String] Base64 encoded template document.
22
22
  # Supported formats are RTF, DOC, DOCX and TX.
@@ -59,7 +59,7 @@ module TXTextControl
59
59
  return {
60
60
  "mergeData" => @merge_data,
61
61
  "template" => @template,
62
- "mergeSettings" => @merge_settings.nil? ? nil : merge_settings.to_camelized_hash
62
+ "mergeSettings" => @merge_settings.nil? ? nil : @merge_settings.to_camelized_hash
63
63
  }
64
64
  end
65
65
  end
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  module TXTextControl
15
15
  module ReportingCloud
@@ -9,7 +9,9 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
+
14
+ require "txtextcontrol/reportingcloud/document_settings"
13
15
 
14
16
  module TXTextControl
15
17
  module ReportingCloud
@@ -27,25 +29,13 @@ module TXTextControl
27
29
  # formatted Html content or not. The default value is false. Html
28
30
  # content must be enclosed in an <html /> tag element. Only active in
29
31
  # the Merge endpoint.
30
- # @attr author [String] The document's author.
31
- # @attr creation_date [DateTime] The document's creation date.
32
- # @attr creator_application [String] The application which created the document.
33
- # @attr document_subject [String] The document's subject.
34
- # @attr document_title [String] The document's title.
35
- # @attr last_modification_date [DateTime] The document's last modification date.
36
- # @attr user_password [String] The password needed to open the document.
37
32
  # @author Thorsten Kummerow (@thomerow)
38
- class MergeSettings
33
+ class MergeSettings < DocumentSettings
39
34
  attr_accessor :remove_empty_fields
40
35
  attr_accessor :remove_empty_blocks
41
36
  attr_accessor :remove_empty_images
42
37
  attr_accessor :remove_trailing_whitespace
43
38
  attr_accessor :merge_html
44
- attr_accessor :author
45
- attr_accessor :creator_application
46
- attr_accessor :document_subject
47
- attr_accessor :document_title
48
- attr_accessor :user_password
49
39
 
50
40
  alias_method :remove_empty_fields?, :remove_empty_fields
51
41
  alias_method :remove_empty_blocks?, :remove_empty_blocks
@@ -59,66 +49,20 @@ module TXTextControl
59
49
  @remove_empty_images = true
60
50
  @remove_trailing_whitespace = true
61
51
  @merge_html = false
62
-
63
- @author = nil
64
- @creation_date = nil
65
- @creator_application = nil
66
- @document_subject = nil
67
- @document_title = nil
68
- @last_modification_date = nil
69
- @user_password = nil
70
52
  end
71
-
72
- def creation_date
73
- @creation_date
74
- end
75
-
76
- def creation_date=(val)
77
- case val
78
- when nil
79
- @creation_date = nil
80
- when String
81
- @creation_date = DateTime.iso8601(val)
82
- when DateTime
83
- @creation_date = val
84
- else raise ArgumentError, "Value must be a string or an instance of type DateTime."
85
- end
86
- end
87
-
88
- def last_modification_date
89
- @last_modification_date
90
- end
91
-
92
- def last_modification_date=(val)
93
- case val
94
- when nil
95
- @last_modification_date = nil
96
- when String
97
- @last_modification_date = DateTime.iso8601(val)
98
- when DateTime
99
- @last_modification_date = val
100
- else raise ArgumentError, "Value must be a string or an instance of type DateTime."
101
- end
102
- end
103
-
53
+
104
54
  # Converts a MergeSettings instance to a hash while converting the attribute names
105
55
  # from snake case to camel case.
106
56
  # @return [Hash] A hash representing the MergeSettings instance.
107
57
  def to_camelized_hash
108
- return {
58
+ result = {
109
59
  "removeEmptyFields" => @remove_empty_fields,
110
60
  "removeEmptyBlocks" => @remove_empty_blocks,
111
61
  "removeEmptyImages" => @remove_empty_images,
112
62
  "removeTrailingWhitespace" => @remove_trailing_whitespace,
113
63
  "mergeHtml" => @merge_html,
114
- "author" => @author,
115
- "creationDate" => @creation_date.nil? ? nil : @creation_date.iso8601,
116
- "creatorApplication" => @creator_application,
117
- "documentSubject" => @document_subject,
118
- "documentTitle" => @document_title,
119
- "lastModificationDate" => @last_modification_date.nil? ? nil : @last_modification_date.iso8601,
120
- "userPassword" => @user_password
121
64
  }
65
+ result.merge(super)
122
66
  end
123
67
  end
124
68
  end
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  require "uri"
15
15
  require "net/http"
@@ -23,6 +23,8 @@ require 'txtextcontrol/reportingcloud/incorrect_word'
23
23
  require 'txtextcontrol/reportingcloud/find_and_replace_body'
24
24
  require 'txtextcontrol/reportingcloud/template_name_validator'
25
25
  require 'txtextcontrol/reportingcloud/template_data_validator'
26
+ require 'txtextcontrol/reportingcloud/api_key'
27
+ require 'txtextcontrol/reportingcloud/append_body'
26
28
  require 'core_ext/string'
27
29
 
28
30
  module TXTextControl
@@ -125,6 +127,34 @@ module TXTextControl
125
127
  end
126
128
  end
127
129
 
130
+ # Combines documents by appending them divided by a new section, paragraph or nothing.
131
+ # @param append_body [TXTextControl::ReportingCloud::AppendBody] The AppendBody object
132
+ # contains the templates and a DocumentSettings object.
133
+ # @param return_format [Symbol] The format of the created document. Possible
134
+ # values are +:pdf+, +:rtf+, +:doc+, +:docx+, +:html+ and +:tx+.
135
+ # @param test [Boolean] Specifies whether it is a test run or not. A test run is
136
+ # not counted against the quota and created documents contain a watermark.
137
+ # @return [String] The resulting document as a Base64 string.
138
+ def append_documents(append_body, return_format = :pdf, test = false)
139
+ unless append_body.is_a?(TXTextControl::ReportingCloud::AppendBody)
140
+ raise ArgumentError, "append_body must be an AppendBody instance."
141
+ end
142
+
143
+ # Create query parameters
144
+ params = {
145
+ :returnFormat => return_format,
146
+ :test => test
147
+ }
148
+
149
+ # Send request
150
+ res = request("/document/append", :post, params, append_body)
151
+ if res.kind_of? Net::HTTPSuccess
152
+ return res.body.remove_first_and_last
153
+ else
154
+ raise res.body
155
+ end
156
+ end
157
+
128
158
  # Returns the account settings.
129
159
  # @return [AccountSettings] The account settings.
130
160
  def get_account_settings
@@ -132,7 +162,7 @@ module TXTextControl
132
162
  if res.kind_of? Net::HTTPSuccess
133
163
  return AccountSettings.from_camelized_hash(JSON.parse(res.body))
134
164
  else
135
- raise res.body
165
+ raise res.body
136
166
  end
137
167
  end
138
168
 
@@ -418,6 +448,50 @@ module TXTextControl
418
448
  end
419
449
  end
420
450
 
451
+ # Creates and returns a new API key.
452
+ # @return [String] The new API key.
453
+ def create_api_key
454
+ res = request("/account/apikey", :put)
455
+ if res.kind_of? Net::HTTPSuccess
456
+ return res.body.remove_first_and_last
457
+ else
458
+ raise res.body
459
+ end
460
+ end
461
+
462
+ # Deletes a given API Key from the account.
463
+ # @param key [String] The key to delete from the account.
464
+ def delete_api_key(key)
465
+ # Parameter validation
466
+ unless !key.nil? && !key.to_s.empty?
467
+ raise ArgumentError, "The given key must not be empty."
468
+ end
469
+
470
+ # Create query parameters
471
+ params = {
472
+ :key => key
473
+ }
474
+
475
+ res = request("/account/apikey", :delete, params)
476
+ raise res.body unless res.kind_of? Net::HTTPSuccess
477
+ end
478
+
479
+ # Returns all available API Keys of the current account.
480
+ # @return [Array<String>] All available API Keys of the current account.
481
+ def get_api_keys
482
+ res = request("/account/apikeys", :get)
483
+ if res.kind_of? Net::HTTPSuccess
484
+ keys = Array.new
485
+ data = JSON.parse(res.body, object_class: OpenStruct)
486
+ data.each do |elem|
487
+ keys.push(APIKey.new(elem.key, elem.active))
488
+ end
489
+ return keys
490
+ else
491
+ raise res.body
492
+ end
493
+ end
494
+
421
495
  # Performs a HTTP request of a given type.
422
496
  # @param request_type [Symbol] The type of the request. Possible values are +:get+,
423
497
  # +:post+ and +:delete+.
@@ -442,6 +516,8 @@ module TXTextControl
442
516
  req_type = Net::HTTP::Post
443
517
  when :delete
444
518
  req_type = Net::HTTP::Delete
519
+ when :put
520
+ req_type = Net::HTTP::Put
445
521
  else raise "Unknown HTTP request type."
446
522
  end
447
523
 
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  require 'date'
15
15
 
@@ -36,6 +36,7 @@ module TXTextControl
36
36
  end
37
37
  @size = size
38
38
  end
39
+
39
40
  end
40
41
  end
41
42
  end
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  module TXTextControl
15
15
  module ReportingCloud
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  require 'txtextcontrol/reportingcloud/merge_field'
15
15
  require 'txtextcontrol/reportingcloud/merge_block'
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  module TXTextControl
15
15
  module ReportingCloud
@@ -9,10 +9,10 @@
9
9
  #
10
10
  # License: https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-ruby/master/LICENSE.md
11
11
  #
12
- # Copyright: © 2017 Text Control GmbH
12
+ # Copyright: © 2019 Text Control GmbH
13
13
 
14
14
  module TXTextControl
15
15
  module ReportingCloud
16
- VERSION = "1.1.1"
16
+ VERSION = "1.2.0"
17
17
  end
18
18
  end
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.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Kummerow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-24 00:00:00.000000000 Z
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,6 +62,8 @@ extra_rdoc_files: []
62
62
  files:
63
63
  - ".gitignore"
64
64
  - ".rspec"
65
+ - ".vscode/launch.json"
66
+ - ".vscode/settings.json"
65
67
  - Gemfile
66
68
  - LICENSE.md
67
69
  - README.md
@@ -71,6 +73,10 @@ files:
71
73
  - lib/core_ext/string.rb
72
74
  - lib/txtextcontrol/reportingcloud.rb
73
75
  - lib/txtextcontrol/reportingcloud/account_settings.rb
76
+ - lib/txtextcontrol/reportingcloud/api_key.rb
77
+ - lib/txtextcontrol/reportingcloud/append_body.rb
78
+ - lib/txtextcontrol/reportingcloud/append_document.rb
79
+ - lib/txtextcontrol/reportingcloud/document_settings.rb
74
80
  - lib/txtextcontrol/reportingcloud/find_and_replace_body.rb
75
81
  - lib/txtextcontrol/reportingcloud/incorrect_word.rb
76
82
  - lib/txtextcontrol/reportingcloud/merge_block.rb