cpaas_test_ruby 0.1.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 +7 -0
- data/.devcontainer/devcontainer.json +38 -0
- data/.devcontainer/docker/ruby/Dockerfile +39 -0
- data/.devcontainer/docker-compose.yml +17 -0
- data/.devcontainer/lifecycle/initialize-command.sh +6 -0
- data/.rspec +3 -0
- data/.rubocop.yml +34 -0
- data/.vscode/launch.json +32 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/Rakefile +8 -0
- data/lib/cpaas_test_ruby/config.rb +78 -0
- data/lib/cpaas_test_ruby/exception/bad_request_exception.rb +10 -0
- data/lib/cpaas_test_ruby/exception/bulk_message_create_failed_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/bulk_message_list_message_retry_limit_exceed_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/bulk_message_show_retry_limit_exceed_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/file_download_failed_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/file_not_found_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/file_upload_failed_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/forbidden_exception.rb +10 -0
- data/lib/cpaas_test_ruby/exception/invalid_params_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/invalid_request_options_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/karaden_exception.rb +15 -0
- data/lib/cpaas_test_ruby/exception/not_found_exception.rb +10 -0
- data/lib/cpaas_test_ruby/exception/too_many_requests_exception.rb +10 -0
- data/lib/cpaas_test_ruby/exception/unauthorized_exception.rb +10 -0
- data/lib/cpaas_test_ruby/exception/unexpected_value_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/unknown_error_exception.rb +9 -0
- data/lib/cpaas_test_ruby/exception/unprocessable_entity_exception.rb +10 -0
- data/lib/cpaas_test_ruby/model/bulk_file.rb +34 -0
- data/lib/cpaas_test_ruby/model/bulk_message.rb +53 -0
- data/lib/cpaas_test_ruby/model/collection.rb +15 -0
- data/lib/cpaas_test_ruby/model/error.rb +19 -0
- data/lib/cpaas_test_ruby/model/karaden_object.rb +31 -0
- data/lib/cpaas_test_ruby/model/message.rb +134 -0
- data/lib/cpaas_test_ruby/model/requestable.rb +29 -0
- data/lib/cpaas_test_ruby/net/no_contents_response.rb +80 -0
- data/lib/cpaas_test_ruby/net/requestor.rb +55 -0
- data/lib/cpaas_test_ruby/net/requestor_interface.rb +9 -0
- data/lib/cpaas_test_ruby/net/response.rb +79 -0
- data/lib/cpaas_test_ruby/net/response_interface.rb +25 -0
- data/lib/cpaas_test_ruby/param/message/bulk/bulk_message_create_params.rb +78 -0
- data/lib/cpaas_test_ruby/param/message/bulk/bulk_message_download_params.rb +126 -0
- data/lib/cpaas_test_ruby/param/message/bulk/bulk_message_list_message_params.rb +72 -0
- data/lib/cpaas_test_ruby/param/message/bulk/bulk_message_params.rb +15 -0
- data/lib/cpaas_test_ruby/param/message/bulk/bulk_message_show_params.rb +72 -0
- data/lib/cpaas_test_ruby/param/message/message_cancel_params.rb +70 -0
- data/lib/cpaas_test_ruby/param/message/message_create_params.rb +152 -0
- data/lib/cpaas_test_ruby/param/message/message_detail_params.rb +70 -0
- data/lib/cpaas_test_ruby/param/message/message_list_params.rb +106 -0
- data/lib/cpaas_test_ruby/param/message/message_params.rb +12 -0
- data/lib/cpaas_test_ruby/request_options.rb +142 -0
- data/lib/cpaas_test_ruby/service/bulk_message_service.rb +90 -0
- data/lib/cpaas_test_ruby/utility.rb +65 -0
- data/lib/cpaas_test_ruby.rb +51 -0
- data/mock/2023-01-01.yaml +776 -0
- data/mock/2023-12-01.yaml +783 -0
- data/mock/2024-03-01.yaml +1061 -0
- data/mock/latest +1 -0
- data/package-lock.json +3474 -0
- data/package.json +21 -0
- data/sig/karaden.rbs +0 -0
- metadata +197 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module Karaden
|
|
2
|
+
module Param
|
|
3
|
+
module Message
|
|
4
|
+
module Bulk
|
|
5
|
+
class BulkMessageShowParams < BulkMessageParams
|
|
6
|
+
attr_accessor :id
|
|
7
|
+
|
|
8
|
+
def initialize()
|
|
9
|
+
@id = nil
|
|
10
|
+
super
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def to_path
|
|
14
|
+
"#{CONTEXT_PATH}/#{@id}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def validate
|
|
18
|
+
errors = Karaden::Model::KaradenObject.new
|
|
19
|
+
has_error = false
|
|
20
|
+
|
|
21
|
+
messages = validate_id
|
|
22
|
+
unless messages.empty?
|
|
23
|
+
errors.set_property('id', messages)
|
|
24
|
+
has_error = true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
if has_error
|
|
28
|
+
e = Karaden::Exception::InvalidParamsException.new
|
|
29
|
+
error = Karaden::Model::Error.new
|
|
30
|
+
error.set_property('object', Karaden::Model::Error::OBJECT_NAME)
|
|
31
|
+
error.set_property('errors', errors)
|
|
32
|
+
e.error = error
|
|
33
|
+
raise e
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
self
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.new_builder
|
|
40
|
+
BulkMessageShowParamsBuilder.new
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
protected
|
|
44
|
+
|
|
45
|
+
def validate_id
|
|
46
|
+
messages = []
|
|
47
|
+
if @id.nil? || @id == ''
|
|
48
|
+
messages << 'idは必須です。'
|
|
49
|
+
messages << '文字列(UUID)を入力してください。'
|
|
50
|
+
end
|
|
51
|
+
messages
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class BulkMessageShowParamsBuilder
|
|
56
|
+
def initialize
|
|
57
|
+
@params = BulkMessageShowParams.new
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def with_id(id)
|
|
61
|
+
@params.id = id
|
|
62
|
+
self
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def build
|
|
66
|
+
@params.clone
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Karaden
|
|
2
|
+
module Param
|
|
3
|
+
module Message
|
|
4
|
+
class MessageCancelParams < MessageParams
|
|
5
|
+
attr_accessor :id
|
|
6
|
+
|
|
7
|
+
def initialize()
|
|
8
|
+
@id = nil
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def to_path
|
|
13
|
+
"#{CONTEXT_PATH}/#{@id}/cancel"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def validate
|
|
17
|
+
errors = Karaden::Model::KaradenObject.new
|
|
18
|
+
has_error = false
|
|
19
|
+
|
|
20
|
+
messages = validate_id
|
|
21
|
+
unless messages.empty?
|
|
22
|
+
errors.set_property('id', messages)
|
|
23
|
+
has_error = true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
if has_error
|
|
27
|
+
e = Karaden::Exception::InvalidParamsException.new
|
|
28
|
+
error = Karaden::Model::Error.new
|
|
29
|
+
error.set_property('object', Karaden::Model::Error::OBJECT_NAME)
|
|
30
|
+
error.set_property('errors', errors)
|
|
31
|
+
e.error = error
|
|
32
|
+
raise e
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
self
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.new_builder
|
|
39
|
+
MessageCancelParamsBuilder.new
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
protected
|
|
43
|
+
|
|
44
|
+
def validate_id
|
|
45
|
+
messages = []
|
|
46
|
+
if @id.nil? || @id == ''
|
|
47
|
+
messages << 'idは必須です。'
|
|
48
|
+
messages << '文字列(UUID)を入力してください。'
|
|
49
|
+
end
|
|
50
|
+
messages
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class MessageCancelParamsBuilder
|
|
55
|
+
def initialize
|
|
56
|
+
@params = MessageCancelParams.new
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def with_id(id)
|
|
60
|
+
@params.id = id
|
|
61
|
+
self
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def build
|
|
65
|
+
@params.clone
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
module Karaden
|
|
2
|
+
module Param
|
|
3
|
+
module Message
|
|
4
|
+
class MessageCreateParams < MessageParams
|
|
5
|
+
attr_accessor :service_id, :to, :body, :tags, :is_shorten, :scheduled_at, :limited_at
|
|
6
|
+
|
|
7
|
+
def initialize()
|
|
8
|
+
@service_id = nil
|
|
9
|
+
@to = nil
|
|
10
|
+
@body = nil
|
|
11
|
+
@tags = nil
|
|
12
|
+
@is_shorten = nil
|
|
13
|
+
@scheduled_at = nil
|
|
14
|
+
@limited_at = nil
|
|
15
|
+
super
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to_path
|
|
19
|
+
CONTEXT_PATH
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def to_data
|
|
23
|
+
{
|
|
24
|
+
service_id: @service_id,
|
|
25
|
+
to: @to,
|
|
26
|
+
body: @body,
|
|
27
|
+
'tags[]' => @tags,
|
|
28
|
+
is_shorten: if @is_shorten.nil?
|
|
29
|
+
nil
|
|
30
|
+
else
|
|
31
|
+
@is_shorten ? 'true' : 'false'
|
|
32
|
+
end,
|
|
33
|
+
scheduled_at: @scheduled_at&.iso8601,
|
|
34
|
+
limited_at: @limited_at&.iso8601
|
|
35
|
+
}.reject { |_, value| value.nil? }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def validate
|
|
39
|
+
errors = Karaden::Model::KaradenObject.new
|
|
40
|
+
has_error = false
|
|
41
|
+
|
|
42
|
+
messages = validate_service_id
|
|
43
|
+
unless messages.empty?
|
|
44
|
+
errors.set_property('service_id', messages)
|
|
45
|
+
has_error = true
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
messages = validate_to
|
|
49
|
+
unless messages.empty?
|
|
50
|
+
errors.set_property('to', messages)
|
|
51
|
+
has_error = true
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
messages = validate_body
|
|
55
|
+
unless messages.empty?
|
|
56
|
+
errors.set_property('body', messages)
|
|
57
|
+
has_error = true
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if has_error
|
|
61
|
+
e = Karaden::Exception::InvalidParamsException.new
|
|
62
|
+
error = Karaden::Model::Error.new
|
|
63
|
+
error.set_property('object', Karaden::Model::Error::OBJECT_NAME)
|
|
64
|
+
error.set_property('errors', errors)
|
|
65
|
+
e.error = error
|
|
66
|
+
raise e
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
self
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.new_builder
|
|
73
|
+
MessageCreateParamsBuilder.new
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
protected
|
|
77
|
+
|
|
78
|
+
def validate_service_id
|
|
79
|
+
messages = []
|
|
80
|
+
if @service_id.nil? || @service_id == ''
|
|
81
|
+
messages << 'service_idは必須です。'
|
|
82
|
+
messages << '数字を入力してください。'
|
|
83
|
+
end
|
|
84
|
+
messages
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def validate_to
|
|
88
|
+
messages = []
|
|
89
|
+
if @to.nil? || @to == ''
|
|
90
|
+
messages << 'toは必須です。'
|
|
91
|
+
messages << '文字列を入力してください。'
|
|
92
|
+
end
|
|
93
|
+
messages
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def validate_body
|
|
97
|
+
messages = []
|
|
98
|
+
if @body.nil? || @body == ''
|
|
99
|
+
messages << 'bodyは必須です。'
|
|
100
|
+
messages << '文字列を入力してください。'
|
|
101
|
+
end
|
|
102
|
+
messages
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
class MessageCreateParamsBuilder
|
|
107
|
+
def initialize
|
|
108
|
+
@params = MessageCreateParams.new
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def with_service_id(service_id)
|
|
112
|
+
@params.service_id = service_id
|
|
113
|
+
self
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def with_to(to)
|
|
117
|
+
@params.to = to
|
|
118
|
+
self
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def with_body(body)
|
|
122
|
+
@params.body = body
|
|
123
|
+
self
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def with_tags(tags)
|
|
127
|
+
@params.tags = tags
|
|
128
|
+
self
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def with_is_shorten(is_shorten)
|
|
132
|
+
@params.is_shorten = is_shorten
|
|
133
|
+
self
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def with_scheduled_at(scheduled_at)
|
|
137
|
+
@params.scheduled_at = scheduled_at
|
|
138
|
+
self
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def with_limited_at(limited_at)
|
|
142
|
+
@params.limited_at = limited_at
|
|
143
|
+
self
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def build
|
|
147
|
+
@params.clone
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Karaden
|
|
2
|
+
module Param
|
|
3
|
+
module Message
|
|
4
|
+
class MessageDetailParams < MessageParams
|
|
5
|
+
attr_accessor :id
|
|
6
|
+
|
|
7
|
+
def initialize()
|
|
8
|
+
@id = nil
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def to_path
|
|
13
|
+
"#{CONTEXT_PATH}/#{@id}"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def validate
|
|
17
|
+
errors = Karaden::Model::KaradenObject.new
|
|
18
|
+
has_error = false
|
|
19
|
+
|
|
20
|
+
messages = validate_id
|
|
21
|
+
unless messages.empty?
|
|
22
|
+
errors.set_property('id', messages)
|
|
23
|
+
has_error = true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
if has_error
|
|
27
|
+
e = Karaden::Exception::InvalidParamsException.new
|
|
28
|
+
error = Karaden::Model::Error.new
|
|
29
|
+
error.set_property('object', Karaden::Model::Error::OBJECT_NAME)
|
|
30
|
+
error.set_property('errors', errors)
|
|
31
|
+
e.error = error
|
|
32
|
+
raise e
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
self
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.new_builder
|
|
39
|
+
MessageDetailParamsBuilder.new
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
protected
|
|
43
|
+
|
|
44
|
+
def validate_id
|
|
45
|
+
messages = []
|
|
46
|
+
if @id.nil? || @id == ''
|
|
47
|
+
messages << 'idは必須です。'
|
|
48
|
+
messages << '文字列(UUID)を入力してください。'
|
|
49
|
+
end
|
|
50
|
+
messages
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class MessageDetailParamsBuilder
|
|
55
|
+
def initialize
|
|
56
|
+
@params = MessageDetailParams.new
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def with_id(id)
|
|
60
|
+
@params.id = id
|
|
61
|
+
self
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def build
|
|
65
|
+
@params.clone
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
module Karaden
|
|
2
|
+
module Param
|
|
3
|
+
module Message
|
|
4
|
+
class MessageListParams < MessageParams
|
|
5
|
+
attr_accessor :service_id, :to, :status, :result, :sent_result, :tag, :start_at, :end_at, :page, :per_page
|
|
6
|
+
|
|
7
|
+
def initialize()
|
|
8
|
+
@service_id = nil
|
|
9
|
+
@to = nil
|
|
10
|
+
@status = nil
|
|
11
|
+
@result = nil
|
|
12
|
+
@sent_result = nil
|
|
13
|
+
@tag = nil
|
|
14
|
+
@start_at = nil
|
|
15
|
+
@end_at = nil
|
|
16
|
+
@page = nil
|
|
17
|
+
@per_page = nil
|
|
18
|
+
super
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_path
|
|
22
|
+
CONTEXT_PATH
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def to_params
|
|
26
|
+
{
|
|
27
|
+
service_id: @service_id,
|
|
28
|
+
to: @to,
|
|
29
|
+
status: @status,
|
|
30
|
+
result: @result,
|
|
31
|
+
sent_result: @sent_result,
|
|
32
|
+
tag: @tag,
|
|
33
|
+
start_at: @start_at&.iso8601,
|
|
34
|
+
end_at: @end_at&.iso8601,
|
|
35
|
+
page: @page,
|
|
36
|
+
per_page: @per_page
|
|
37
|
+
}.reject { |_, value| value.nil? }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.new_builder
|
|
41
|
+
MessageListParamsBuilder.new
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class MessageListParamsBuilder
|
|
46
|
+
def initialize
|
|
47
|
+
@params = MessageListParams.new
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def with_service_id(service_id)
|
|
51
|
+
@params.service_id = service_id
|
|
52
|
+
self
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def with_to(to)
|
|
56
|
+
@params.to = to
|
|
57
|
+
self
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def with_status(status)
|
|
61
|
+
@params.status = status
|
|
62
|
+
self
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def with_result(result)
|
|
66
|
+
@params.result = result
|
|
67
|
+
self
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def with_sent_result(sent_result)
|
|
71
|
+
@params.sent_result = sent_result
|
|
72
|
+
self
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def with_tag(tag)
|
|
76
|
+
@params.tag = tag
|
|
77
|
+
self
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def with_start_at(start_at)
|
|
81
|
+
@params.start_at = start_at
|
|
82
|
+
self
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def with_end_at(end_at)
|
|
86
|
+
@params.end_at = end_at
|
|
87
|
+
self
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def with_page(page)
|
|
91
|
+
@params.page = page
|
|
92
|
+
self
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def with_per_page(per_page)
|
|
96
|
+
@params.per_page = per_page
|
|
97
|
+
self
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def build
|
|
101
|
+
@params.clone
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
module Karaden
|
|
2
|
+
class RequestOptions
|
|
3
|
+
attr_accessor :api_base, :api_key, :api_version, :tenant_id, :user_agent, :connection_timeout, :read_timeout
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
@api_base = nil
|
|
7
|
+
@api_key = nil
|
|
8
|
+
@api_version = nil
|
|
9
|
+
@tenant_id = nil
|
|
10
|
+
@user_agent = nil
|
|
11
|
+
@connection_timeout = nil
|
|
12
|
+
@read_timeout = nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def base_uri
|
|
16
|
+
"#{@api_base}/#{@tenant_id}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def merge(source)
|
|
20
|
+
clone.tap do |obj|
|
|
21
|
+
%i[api_base api_key api_version tenant_id user_agent].each do |prop|
|
|
22
|
+
val = source.send(prop)
|
|
23
|
+
obj.send("#{prop}=", val) unless val.nil?
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def validate
|
|
29
|
+
errors = Karaden::Model::KaradenObject.new
|
|
30
|
+
|
|
31
|
+
messages = validate_api_base
|
|
32
|
+
errors.set_property('api_base', messages) unless messages.empty?
|
|
33
|
+
|
|
34
|
+
messages = validate_api_key
|
|
35
|
+
errors.set_property('api_key', messages) unless messages.empty?
|
|
36
|
+
|
|
37
|
+
messages = validate_api_version
|
|
38
|
+
errors.set_property('api_version', messages) unless messages.empty?
|
|
39
|
+
|
|
40
|
+
messages = validate_tenant_id
|
|
41
|
+
errors.set_property('tenant_id', messages) unless messages.empty?
|
|
42
|
+
|
|
43
|
+
unless errors.property_keys.filter { |key| !errors.property(key).nil? }.empty?
|
|
44
|
+
e = Karaden::Exception::InvalidRequestOptionsException.new
|
|
45
|
+
error = Karaden::Model::Error.new
|
|
46
|
+
error.set_property('object', Karaden::Model::Error::OBJECT_NAME)
|
|
47
|
+
error.set_property('errors', errors)
|
|
48
|
+
e.error = error
|
|
49
|
+
raise e
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
self
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.new_builder
|
|
56
|
+
RequestOptionsBuilder.new
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
protected
|
|
60
|
+
|
|
61
|
+
def validate_api_base
|
|
62
|
+
messages = []
|
|
63
|
+
if @api_base.nil? || @api_base == ''
|
|
64
|
+
messages << 'api_baseは必須です。'
|
|
65
|
+
messages << '文字列を入力してください。'
|
|
66
|
+
end
|
|
67
|
+
messages
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def validate_api_key
|
|
71
|
+
messages = []
|
|
72
|
+
if @api_key.nil? || @api_key == ''
|
|
73
|
+
messages << 'api_keyは必須です。'
|
|
74
|
+
messages << '文字列を入力してください。'
|
|
75
|
+
end
|
|
76
|
+
messages
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def validate_api_version
|
|
80
|
+
messages = []
|
|
81
|
+
if @api_version.nil? || @api_version == ''
|
|
82
|
+
messages << 'api_versionは必須です。'
|
|
83
|
+
messages << '文字列を入力してください。'
|
|
84
|
+
end
|
|
85
|
+
messages
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def validate_tenant_id
|
|
89
|
+
messages = []
|
|
90
|
+
if @tenant_id.nil? || @tenant_id == ''
|
|
91
|
+
messages << 'tenant_idは必須です。'
|
|
92
|
+
messages << '文字列を入力してください。'
|
|
93
|
+
end
|
|
94
|
+
messages
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
class RequestOptionsBuilder
|
|
99
|
+
def initialize
|
|
100
|
+
@request_options = RequestOptions.new
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def with_api_base(api_base)
|
|
104
|
+
@request_options.api_base = api_base
|
|
105
|
+
self
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def with_api_key(api_key)
|
|
109
|
+
@request_options.api_key = api_key
|
|
110
|
+
self
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def with_api_version(api_version)
|
|
114
|
+
@request_options.api_version = api_version
|
|
115
|
+
self
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def with_tenant_id(tenant_id)
|
|
119
|
+
@request_options.tenant_id = tenant_id
|
|
120
|
+
self
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def with_user_agent(user_agent)
|
|
124
|
+
@request_options.user_agent = user_agent
|
|
125
|
+
self
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def with_connection_timeout(connection_timeout)
|
|
129
|
+
@request_options.connection_timeout = connection_timeout
|
|
130
|
+
self
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def with_read_timeout(read_timeout)
|
|
134
|
+
@request_options.read_timeout = read_timeout
|
|
135
|
+
self
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def build
|
|
139
|
+
@request_options.clone
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|