zammad_api 1.4.0 → 2.0.0.alpha1
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 +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.md +235 -0
- data/LICENSE.AGPL.txt +661 -0
- data/LICENSE.MIT.txt +7 -0
- data/LICENSE.md +6 -0
- data/README.md +794 -0
- data/UPGRADING.md +158 -0
- data/lib/zammad_api/attribute_access.rb +121 -0
- data/lib/zammad_api/client.rb +243 -43
- data/lib/zammad_api/collection.rb +233 -0
- data/lib/zammad_api/config.rb +239 -0
- data/lib/zammad_api/deep_copy.rb +43 -0
- data/lib/zammad_api/errors.rb +97 -35
- data/lib/zammad_api/resource_proxy.rb +195 -0
- data/lib/zammad_api/resources/base.rb +196 -93
- data/lib/zammad_api/resources/group.rb +12 -2
- data/lib/zammad_api/resources/organization.rb +12 -2
- data/lib/zammad_api/resources/ticket.rb +42 -19
- data/lib/zammad_api/resources/ticket_article.rb +14 -7
- data/lib/zammad_api/resources/ticket_article_attachment.rb +29 -13
- data/lib/zammad_api/resources/ticket_priority.rb +10 -2
- data/lib/zammad_api/resources/ticket_state.rb +9 -2
- data/lib/zammad_api/resources/user.rb +16 -2
- data/lib/zammad_api/resources.rb +13 -13
- data/lib/zammad_api/response.rb +52 -0
- data/lib/zammad_api/transport.rb +212 -40
- data/lib/zammad_api/version.rb +4 -1
- data/lib/zammad_api.rb +16 -3
- data/sig/zammad_api/attribute_access.rbs +31 -0
- data/sig/zammad_api/client.rbs +42 -0
- data/sig/zammad_api/collection.rbs +46 -0
- data/sig/zammad_api/config.rbs +69 -0
- data/sig/zammad_api/deep_copy.rbs +7 -0
- data/sig/zammad_api/errors.rbs +61 -0
- data/sig/zammad_api/resource_proxy.rbs +41 -0
- data/sig/zammad_api/resources/base.rbs +66 -0
- data/sig/zammad_api/resources/resources.rbs +201 -0
- data/sig/zammad_api/response.rbs +16 -0
- data/sig/zammad_api/transport.rbs +47 -0
- data/sig/zammad_api.rbs +3 -0
- metadata +69 -15
- data/lib/zammad_api/dispatcher.rb +0 -12
- data/lib/zammad_api/json_helper.rb +0 -11
- data/lib/zammad_api/list_all.rb +0 -11
- data/lib/zammad_api/list_base.rb +0 -84
- data/lib/zammad_api/list_search.rb +0 -11
- data/lib/zammad_api/log.rb +0 -18
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module ZammadAPI
|
|
2
|
+
# Built with Data.define; the generated readers are declared explicitly.
|
|
3
|
+
#
|
|
4
|
+
# `middleware` is a block handed a Faraday::Connection, but it is declared
|
|
5
|
+
# untyped here: these signatures ship with the gem, while the Faraday
|
|
6
|
+
# declarations they would need live in sig/vendor, which does not. Naming
|
|
7
|
+
# Faraday here fails `rbs validate` for every consumer.
|
|
8
|
+
class Config < ::Data
|
|
9
|
+
DEFAULT_TIMEOUT: Integer
|
|
10
|
+
DEFAULT_OPEN_TIMEOUT: Integer
|
|
11
|
+
DEFAULT_RETRIES: Integer
|
|
12
|
+
DEFAULT_RETRY_INTERVAL: Float
|
|
13
|
+
REDACTION: String
|
|
14
|
+
DEFAULT_USER_AGENT: String
|
|
15
|
+
CREDENTIAL_OPTIONS: Hash[Symbol, Array[Symbol]]
|
|
16
|
+
|
|
17
|
+
def self.new: (**untyped) -> instance
|
|
18
|
+
def self.merge_options: (Hash[Symbol, untyped] options, Hash[Symbol, untyped] overrides) -> Hash[Symbol, untyped]
|
|
19
|
+
|
|
20
|
+
attr_reader url: String
|
|
21
|
+
attr_reader user: String?
|
|
22
|
+
attr_reader password: String?
|
|
23
|
+
attr_reader http_token: String?
|
|
24
|
+
attr_reader oauth2_token: String?
|
|
25
|
+
attr_reader user_agent: String
|
|
26
|
+
attr_reader timeout: Numeric
|
|
27
|
+
attr_reader open_timeout: Numeric
|
|
28
|
+
attr_reader retries: Integer
|
|
29
|
+
attr_reader retry_interval: Numeric
|
|
30
|
+
attr_reader ssl_verify: bool
|
|
31
|
+
attr_reader proxy: String?
|
|
32
|
+
attr_reader adapter: Symbol?
|
|
33
|
+
attr_reader middleware: untyped
|
|
34
|
+
attr_reader logger: Logger
|
|
35
|
+
|
|
36
|
+
def initialize: (
|
|
37
|
+
url: untyped,
|
|
38
|
+
?user: String?,
|
|
39
|
+
?password: String?,
|
|
40
|
+
?http_token: String?,
|
|
41
|
+
?oauth2_token: String?,
|
|
42
|
+
?user_agent: String?,
|
|
43
|
+
?timeout: untyped,
|
|
44
|
+
?open_timeout: untyped,
|
|
45
|
+
?retries: untyped,
|
|
46
|
+
?retry_interval: untyped,
|
|
47
|
+
?ssl_verify: bool,
|
|
48
|
+
?proxy: String?,
|
|
49
|
+
?adapter: (Symbol | String)?,
|
|
50
|
+
?middleware: untyped,
|
|
51
|
+
?logger: Logger?
|
|
52
|
+
) -> void
|
|
53
|
+
|
|
54
|
+
def authentication_scheme: () -> Symbol
|
|
55
|
+
def with: (**untyped) -> Config
|
|
56
|
+
def inspect: () -> String
|
|
57
|
+
def to_s: () -> String
|
|
58
|
+
def pretty_print: (untyped printer) -> void
|
|
59
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
def render: (Symbol, untyped) -> String
|
|
64
|
+
def normalize_url: (untyped) -> String
|
|
65
|
+
def validate_credentials!: () -> void
|
|
66
|
+
def present: (untyped) -> untyped
|
|
67
|
+
def stripped: (untyped) -> String?
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module ZammadAPI
|
|
2
|
+
class Error < StandardError
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
class ConfigurationError < Error
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class UnknownResourceError < Error
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class TransportError < Error
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class ConnectionError < TransportError
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class TimeoutError < TransportError
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class ParseError < Error
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class PaginationError < Error
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class ResponseError < Error
|
|
27
|
+
STATUS_ERRORS: Hash[Integer, singleton(ResponseError)]
|
|
28
|
+
|
|
29
|
+
attr_reader response: Response?
|
|
30
|
+
|
|
31
|
+
def self.build: (Response response, String request) -> ResponseError
|
|
32
|
+
|
|
33
|
+
def initialize: (String message, ?response: Response?) -> void
|
|
34
|
+
def status: () -> Integer?
|
|
35
|
+
def body: () -> untyped
|
|
36
|
+
def headers: () -> Hash[String, String]
|
|
37
|
+
def server_message: () -> String?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class ClientError < ResponseError
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class ServerError < ResponseError
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class AuthenticationError < ClientError
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class AuthorizationError < ClientError
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class NotFoundError < ClientError
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class ValidationError < ClientError
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class RateLimitError < ClientError
|
|
59
|
+
def retry_after: () -> Integer?
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module ZammadAPI
|
|
2
|
+
# Generic over the resource it is the entry point for: `client.tickets` is a
|
|
3
|
+
# ResourceProxy[Resources::Ticket], so `find` answers with a Ticket and a
|
|
4
|
+
# block over it is handed one.
|
|
5
|
+
class ResourceProxy[R < Resources::Base]
|
|
6
|
+
include Enumerable[R]
|
|
7
|
+
|
|
8
|
+
attr_reader resource_class: untyped
|
|
9
|
+
|
|
10
|
+
@transport: Transport
|
|
11
|
+
|
|
12
|
+
def initialize: (Transport, untyped resource_class) -> void
|
|
13
|
+
def new: (?hash[untyped, untyped] attributes) -> R
|
|
14
|
+
def create: (?hash[untyped, untyped] attributes) -> R
|
|
15
|
+
def find: (Integer | String id) -> R
|
|
16
|
+
def find_by: (**untyped) -> R?
|
|
17
|
+
def find_by!: (**untyped) -> R
|
|
18
|
+
def exists?: (Integer | String id) -> bool
|
|
19
|
+
def destroy: (Integer | String id) -> true
|
|
20
|
+
def all: () -> Collection[R]
|
|
21
|
+
def order: (*(Symbol | String) attributes, **(Symbol | String) directions) -> Collection[R]
|
|
22
|
+
|
|
23
|
+
def each: () { (R) -> void } -> Collection[R]
|
|
24
|
+
| () -> Enumerator[R, Collection[R]]
|
|
25
|
+
def find_each: (?batch_size: Integer?) { (R) -> void } -> Collection[R]
|
|
26
|
+
| (?batch_size: Integer?) -> Enumerator[R, Collection[R]]
|
|
27
|
+
def in_batches: (?of: Integer?) { (Array[R]) -> void } -> Collection[R]
|
|
28
|
+
| (?of: Integer?) -> Enumerator[Array[R], Collection[R]]
|
|
29
|
+
def page: (Integer number, ?per_page: Integer?) -> Collection[R]
|
|
30
|
+
def pluck: (*(Symbol | String) keys) -> Array[untyped]
|
|
31
|
+
def empty?: () -> bool
|
|
32
|
+
def first: () -> R?
|
|
33
|
+
| (Integer count) -> Array[R]
|
|
34
|
+
def search: (String term, **untyped filters) -> Collection[R]
|
|
35
|
+
def inspect: () -> String
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def find_by_id: (Hash[Symbol, untyped] params) -> R?
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module ZammadAPI
|
|
2
|
+
module Resources
|
|
3
|
+
class Base
|
|
4
|
+
include AttributeAccess
|
|
5
|
+
|
|
6
|
+
DEFAULT_MAX_PER_PAGE: Integer
|
|
7
|
+
|
|
8
|
+
attr_reader error: ValidationError?
|
|
9
|
+
|
|
10
|
+
# What Zammad stamps every record with. These four are columns of every
|
|
11
|
+
# table, and the two names beside them are what `expand` adds: the login
|
|
12
|
+
# of each user. A record that was built with `new` and not saved yet
|
|
13
|
+
# carries none of them, and reading one then raises NoMethodError - the
|
|
14
|
+
# types here, and on every resource, describe a record Zammad served.
|
|
15
|
+
attr_reader created_by_id: Integer
|
|
16
|
+
attr_reader updated_by_id: Integer
|
|
17
|
+
attr_reader created_at: String
|
|
18
|
+
attr_reader updated_at: String
|
|
19
|
+
attr_reader created_by: String
|
|
20
|
+
attr_reader updated_by: String
|
|
21
|
+
|
|
22
|
+
@new_record: bool
|
|
23
|
+
@destroyed: bool
|
|
24
|
+
@error: ValidationError?
|
|
25
|
+
@baseline: Hash[Symbol, untyped]
|
|
26
|
+
|
|
27
|
+
def self.path: (String) -> void
|
|
28
|
+
def self.searchable: (bool) -> void
|
|
29
|
+
def self.max_per_page: (Integer) -> void
|
|
30
|
+
def self.sortable: (bool) -> void
|
|
31
|
+
def self.resource_path: () -> String
|
|
32
|
+
def self.searchable?: () -> bool
|
|
33
|
+
def self.page_limit: () -> Integer
|
|
34
|
+
def self.sortable?: () -> bool
|
|
35
|
+
def self.member_path: ((Integer | String) id) -> String
|
|
36
|
+
def self.from_response: (Transport, Hash[untyped, untyped] attributes) -> Base
|
|
37
|
+
|
|
38
|
+
def initialize: (Transport, ?hash[untyped, untyped]? attributes) -> void
|
|
39
|
+
def new_record?: () -> bool
|
|
40
|
+
def persisted?: () -> bool
|
|
41
|
+
def destroyed?: () -> bool
|
|
42
|
+
def changes: () -> Hash[Symbol, Array[untyped]]
|
|
43
|
+
def changed?: () -> bool
|
|
44
|
+
def assign_attributes: (hash[untyped, untyped] attributes) -> self
|
|
45
|
+
def save: () -> bool
|
|
46
|
+
def save!: () -> true
|
|
47
|
+
def update: (hash[untyped, untyped] attributes) -> bool
|
|
48
|
+
def update!: (hash[untyped, untyped] attributes) -> true
|
|
49
|
+
def reload: () -> self
|
|
50
|
+
def destroy: () -> true
|
|
51
|
+
def inspect: () -> String
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
attr_reader transport: Transport
|
|
56
|
+
|
|
57
|
+
def mark_persisted!: () -> void
|
|
58
|
+
def load_response!: (Response response) -> void
|
|
59
|
+
def raise_if_new!: (String operation) -> void
|
|
60
|
+
def writable_attributes?: () -> bool
|
|
61
|
+
def write_attribute: (Symbol, untyped) -> untyped
|
|
62
|
+
def member_path: () -> String
|
|
63
|
+
def require_id!: () -> Integer
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
module ZammadAPI
|
|
2
|
+
# The attributes declared on each resource are the long-standing columns
|
|
3
|
+
# of its table, typed the way their JSON arrives - a timestamp is a String,
|
|
4
|
+
# and `preferences` is a Hash with Symbol keys.
|
|
5
|
+
#
|
|
6
|
+
# They are declarations only. A record answers them through
|
|
7
|
+
# method_missing, from whatever the response carried, so nothing here makes
|
|
8
|
+
# an attribute exist: these say what a typed caller may rely on.
|
|
9
|
+
#
|
|
10
|
+
# What is left out, on purpose:
|
|
11
|
+
#
|
|
12
|
+
# - Attributes an administrator added. Reach one with `record[:name]`, or
|
|
13
|
+
# declare it in your own signatures by reopening the class:
|
|
14
|
+
#
|
|
15
|
+
# class ZammadAPI::Resources::Ticket
|
|
16
|
+
# attr_accessor escalation_reason: String?
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# - Columns that newer Zammad versions added, which an older instance does
|
|
20
|
+
# not serve.
|
|
21
|
+
#
|
|
22
|
+
# - The name `expand` adds for an association that may be empty, such as
|
|
23
|
+
# `organization` on a ticket or a user. Zammad leaves the key out rather
|
|
24
|
+
# than sending null, so the reader would raise rather than answer nil.
|
|
25
|
+
# `record[:organization]` is nil in that case, and `organization_id` is
|
|
26
|
+
# always there.
|
|
27
|
+
module Resources
|
|
28
|
+
class Group < Base
|
|
29
|
+
attr_accessor name: String
|
|
30
|
+
attr_accessor signature_id: Integer?
|
|
31
|
+
attr_accessor email_address_id: Integer?
|
|
32
|
+
attr_accessor assignment_timeout: Integer?
|
|
33
|
+
attr_accessor follow_up_possible: String
|
|
34
|
+
attr_accessor follow_up_assignment: bool
|
|
35
|
+
attr_accessor active: bool
|
|
36
|
+
attr_accessor note: String?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class Organization < Base
|
|
40
|
+
attr_accessor name: String
|
|
41
|
+
attr_accessor shared: bool
|
|
42
|
+
attr_accessor domain: String?
|
|
43
|
+
attr_accessor domain_assignment: bool
|
|
44
|
+
attr_accessor active: bool
|
|
45
|
+
attr_accessor note: String?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class TicketPriority < Base
|
|
49
|
+
attr_accessor name: String
|
|
50
|
+
attr_accessor default_create: bool
|
|
51
|
+
attr_accessor ui_icon: String?
|
|
52
|
+
attr_accessor ui_color: String?
|
|
53
|
+
attr_accessor active: bool
|
|
54
|
+
attr_accessor note: String?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class TicketState < Base
|
|
58
|
+
attr_accessor name: String
|
|
59
|
+
attr_accessor state_type_id: Integer
|
|
60
|
+
attr_accessor next_state_id: Integer?
|
|
61
|
+
attr_accessor ignore_escalation: bool
|
|
62
|
+
attr_accessor default_create: bool
|
|
63
|
+
attr_accessor default_follow_up: bool
|
|
64
|
+
attr_accessor active: bool
|
|
65
|
+
attr_accessor note: String?
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
class User < Base
|
|
69
|
+
# Narrowed from Base so Client#me returns the concrete user type.
|
|
70
|
+
def self.from_response: (Transport, Hash[untyped, untyped] attributes) -> User
|
|
71
|
+
|
|
72
|
+
attr_accessor login: String
|
|
73
|
+
attr_accessor firstname: String?
|
|
74
|
+
attr_accessor lastname: String?
|
|
75
|
+
attr_accessor email: String?
|
|
76
|
+
attr_accessor organization_id: Integer?
|
|
77
|
+
attr_accessor image: String?
|
|
78
|
+
attr_accessor image_source: String?
|
|
79
|
+
attr_accessor web: String?
|
|
80
|
+
attr_accessor phone: String?
|
|
81
|
+
attr_accessor fax: String?
|
|
82
|
+
attr_accessor mobile: String?
|
|
83
|
+
attr_accessor department: String?
|
|
84
|
+
attr_accessor street: String?
|
|
85
|
+
attr_accessor zip: String?
|
|
86
|
+
attr_accessor city: String?
|
|
87
|
+
attr_accessor country: String?
|
|
88
|
+
attr_accessor address: String?
|
|
89
|
+
attr_accessor vip: bool
|
|
90
|
+
attr_accessor verified: bool
|
|
91
|
+
attr_accessor active: bool
|
|
92
|
+
attr_accessor note: String?
|
|
93
|
+
attr_accessor out_of_office: bool
|
|
94
|
+
attr_accessor out_of_office_start_at: String?
|
|
95
|
+
attr_accessor out_of_office_end_at: String?
|
|
96
|
+
attr_accessor out_of_office_replacement_id: Integer?
|
|
97
|
+
attr_accessor preferences: Hash[Symbol, untyped]?
|
|
98
|
+
|
|
99
|
+
# Set by Zammad as the user signs in, so there is nothing to write.
|
|
100
|
+
attr_reader last_login: String?
|
|
101
|
+
attr_reader login_failed: Integer
|
|
102
|
+
attr_reader source: String?
|
|
103
|
+
|
|
104
|
+
# Zammad takes a password and never serves one.
|
|
105
|
+
attr_writer password: String
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
class Ticket < Base
|
|
109
|
+
attr_accessor title: String
|
|
110
|
+
attr_accessor group_id: Integer
|
|
111
|
+
attr_accessor state_id: Integer
|
|
112
|
+
attr_accessor priority_id: Integer
|
|
113
|
+
attr_accessor owner_id: Integer
|
|
114
|
+
attr_accessor customer_id: Integer
|
|
115
|
+
attr_accessor organization_id: Integer?
|
|
116
|
+
attr_accessor note: String?
|
|
117
|
+
attr_accessor pending_time: String?
|
|
118
|
+
attr_accessor type: String?
|
|
119
|
+
attr_accessor preferences: Hash[Symbol, untyped]?
|
|
120
|
+
|
|
121
|
+
# The name `expand` puts beside each of the ids above that cannot be
|
|
122
|
+
# empty. Writing one is how a ticket is moved by name:
|
|
123
|
+
# `ticket.update(state: 'closed', group: 'Support')`.
|
|
124
|
+
attr_accessor group: String
|
|
125
|
+
attr_accessor state: String
|
|
126
|
+
attr_accessor priority: String
|
|
127
|
+
attr_accessor owner: String
|
|
128
|
+
attr_accessor customer: String
|
|
129
|
+
|
|
130
|
+
# Kept by Zammad as the ticket moves, so there is nothing to write.
|
|
131
|
+
attr_reader number: String
|
|
132
|
+
attr_reader article_count: Integer?
|
|
133
|
+
attr_reader create_article_type_id: Integer?
|
|
134
|
+
attr_reader create_article_sender_id: Integer?
|
|
135
|
+
attr_reader first_response_at: String?
|
|
136
|
+
attr_reader first_response_escalation_at: String?
|
|
137
|
+
attr_reader first_response_in_min: Integer?
|
|
138
|
+
attr_reader first_response_diff_in_min: Integer?
|
|
139
|
+
attr_reader close_at: String?
|
|
140
|
+
attr_reader close_escalation_at: String?
|
|
141
|
+
attr_reader close_in_min: Integer?
|
|
142
|
+
attr_reader close_diff_in_min: Integer?
|
|
143
|
+
attr_reader update_escalation_at: String?
|
|
144
|
+
attr_reader update_in_min: Integer?
|
|
145
|
+
attr_reader update_diff_in_min: Integer?
|
|
146
|
+
attr_reader escalation_at: String?
|
|
147
|
+
attr_reader last_contact_at: String?
|
|
148
|
+
attr_reader last_contact_agent_at: String?
|
|
149
|
+
attr_reader last_contact_customer_at: String?
|
|
150
|
+
attr_reader last_owner_update_at: String?
|
|
151
|
+
|
|
152
|
+
def articles: () -> Array[TicketArticle]
|
|
153
|
+
def add_article: (?hash[untyped, untyped] attributes) -> TicketArticle
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
class TicketArticle < Base
|
|
157
|
+
# Narrowed from Base so callers get the concrete article type.
|
|
158
|
+
def self.from_response: (Transport, Hash[untyped, untyped] attributes) -> TicketArticle
|
|
159
|
+
|
|
160
|
+
attr_accessor ticket_id: Integer
|
|
161
|
+
attr_accessor type_id: Integer
|
|
162
|
+
attr_accessor sender_id: Integer
|
|
163
|
+
attr_accessor from: String?
|
|
164
|
+
attr_accessor to: String?
|
|
165
|
+
attr_accessor cc: String?
|
|
166
|
+
attr_accessor subject: String?
|
|
167
|
+
attr_accessor reply_to: String?
|
|
168
|
+
attr_accessor in_reply_to: String?
|
|
169
|
+
attr_accessor content_type: String
|
|
170
|
+
attr_accessor body: String
|
|
171
|
+
attr_accessor internal: bool
|
|
172
|
+
attr_accessor preferences: Hash[Symbol, untyped]?
|
|
173
|
+
|
|
174
|
+
# The name `expand` puts beside type_id and sender_id, which is also
|
|
175
|
+
# how an article is given either: `add_article(type: 'note')`.
|
|
176
|
+
attr_accessor type: String
|
|
177
|
+
attr_accessor sender: String
|
|
178
|
+
|
|
179
|
+
attr_reader message_id: String?
|
|
180
|
+
attr_reader message_id_md5: String?
|
|
181
|
+
attr_reader origin_by_id: Integer?
|
|
182
|
+
|
|
183
|
+
def attachments: () -> Array[TicketArticleAttachment]
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
class TicketArticleAttachment
|
|
187
|
+
include AttributeAccess
|
|
188
|
+
|
|
189
|
+
@transport: Transport
|
|
190
|
+
|
|
191
|
+
# What Zammad lists for each attachment of an article.
|
|
192
|
+
attr_reader filename: String
|
|
193
|
+
attr_reader size: String
|
|
194
|
+
attr_reader preferences: Hash[Symbol, untyped]
|
|
195
|
+
|
|
196
|
+
def initialize: (Transport, ?Hash[untyped, untyped]? attributes) -> void
|
|
197
|
+
def download: () -> String
|
|
198
|
+
def inspect: () -> String
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module ZammadAPI
|
|
2
|
+
# Built with Data.define; the generated readers are declared explicitly.
|
|
3
|
+
class Response < ::Data
|
|
4
|
+
attr_reader status: Integer
|
|
5
|
+
attr_reader headers: Hash[String, String]
|
|
6
|
+
attr_reader body: untyped
|
|
7
|
+
attr_reader raw_body: String
|
|
8
|
+
|
|
9
|
+
def self.new: (status: Integer, headers: Hash[String, String], body: untyped, raw_body: String) -> instance
|
|
10
|
+
|
|
11
|
+
def self.decode_body: (String?, String) -> untyped
|
|
12
|
+
|
|
13
|
+
def success?: () -> bool
|
|
14
|
+
def decoded: (Symbol shape) -> untyped
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module ZammadAPI
|
|
2
|
+
# The Faraday connection and responses are untyped here rather than named:
|
|
3
|
+
# these signatures ship with the gem and the Faraday declarations they would
|
|
4
|
+
# need live in sig/vendor, which does not. See sig/zammad_api/config.rbs.
|
|
5
|
+
class Transport
|
|
6
|
+
def get: (String path, **untyped options) -> Response
|
|
7
|
+
def post: (String path, **untyped options) -> Response
|
|
8
|
+
def put: (String path, **untyped options) -> Response
|
|
9
|
+
def delete: (String path, **untyped options) -> Response
|
|
10
|
+
|
|
11
|
+
RETRIABLE_METHODS: Array[Symbol]
|
|
12
|
+
RETRIABLE_STATUSES: Array[Integer]
|
|
13
|
+
RETRIABLE_EXCEPTIONS: Array[untyped]
|
|
14
|
+
SENSITIVE_KEY_PATTERN: Regexp
|
|
15
|
+
# private_constant in the source; RBS has no way to say so.
|
|
16
|
+
ABSOLUTE_URL: Regexp
|
|
17
|
+
|
|
18
|
+
attr_reader config: Config
|
|
19
|
+
attr_reader on_behalf_of: String?
|
|
20
|
+
|
|
21
|
+
@connection: untyped
|
|
22
|
+
|
|
23
|
+
def self.escape_path_segment: (untyped) -> String
|
|
24
|
+
def self.relative_path: (untyped) -> String
|
|
25
|
+
def self.redact_path: (untyped path) -> String
|
|
26
|
+
def self.redact: (untyped value) -> untyped
|
|
27
|
+
|
|
28
|
+
def initialize: (Config, ?on_behalf_of: String?) -> void
|
|
29
|
+
def with_on_behalf_of: (String? identifier) -> Transport
|
|
30
|
+
def with_config: (Config) -> Transport
|
|
31
|
+
def inspect: () -> String
|
|
32
|
+
|
|
33
|
+
def request: (Symbol method, String path, ?query: Hash[Symbol, untyped]?, ?body: untyped, ?headers: Hash[untyped, untyped]?) -> Response
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def perform: (Symbol, String, Hash[Symbol, untyped]?, untyped, Hash[untyped, untyped]?) -> untyped
|
|
38
|
+
def build_connection: () -> untyped
|
|
39
|
+
def retry_options: () -> Hash[Symbol, untyped]
|
|
40
|
+
def apply_authentication: (untyped) -> void
|
|
41
|
+
def decode: (untyped) -> Response
|
|
42
|
+
def log_request: (String, Hash[Symbol, untyped]?, untyped, Hash[untyped, untyped]?) -> void
|
|
43
|
+
def log_response: (String, Response, Float) -> void
|
|
44
|
+
def loggable_body: (untyped body) -> String
|
|
45
|
+
def logger: () -> Logger
|
|
46
|
+
end
|
|
47
|
+
end
|
data/sig/zammad_api.rbs
ADDED
metadata
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zammad_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0.alpha1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Edenhofer
|
|
8
8
|
- Martin Gruner
|
|
9
|
+
- Mantas Masalskis
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
12
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
@@ -16,30 +17,69 @@ dependencies:
|
|
|
16
17
|
requirements:
|
|
17
18
|
- - "~>"
|
|
18
19
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2'
|
|
20
|
+
version: '2.9'
|
|
20
21
|
type: :runtime
|
|
21
22
|
prerelease: false
|
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
24
|
requirements:
|
|
24
25
|
- - "~>"
|
|
25
26
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2'
|
|
27
|
-
|
|
27
|
+
version: '2.9'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: faraday-retry
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '2.2'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '2.2'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: logger
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - "~>"
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '1.5'
|
|
49
|
+
type: :runtime
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - "~>"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '1.5'
|
|
56
|
+
description: Tickets, articles, users, organizations and groups of a Zammad instance
|
|
57
|
+
as records to find, create, update and destroy, with collections that paginate themselves,
|
|
58
|
+
timeouts, retries and an error class per kind of failure.
|
|
28
59
|
email:
|
|
29
60
|
- support@zammad.org
|
|
30
61
|
executables: []
|
|
31
62
|
extensions: []
|
|
32
|
-
extra_rdoc_files:
|
|
63
|
+
extra_rdoc_files:
|
|
64
|
+
- CHANGELOG.md
|
|
65
|
+
- README.md
|
|
66
|
+
- UPGRADING.md
|
|
33
67
|
files:
|
|
68
|
+
- ".yardopts"
|
|
69
|
+
- CHANGELOG.md
|
|
70
|
+
- LICENSE.AGPL.txt
|
|
71
|
+
- LICENSE.MIT.txt
|
|
72
|
+
- LICENSE.md
|
|
73
|
+
- README.md
|
|
74
|
+
- UPGRADING.md
|
|
34
75
|
- lib/zammad_api.rb
|
|
76
|
+
- lib/zammad_api/attribute_access.rb
|
|
35
77
|
- lib/zammad_api/client.rb
|
|
36
|
-
- lib/zammad_api/
|
|
78
|
+
- lib/zammad_api/collection.rb
|
|
79
|
+
- lib/zammad_api/config.rb
|
|
80
|
+
- lib/zammad_api/deep_copy.rb
|
|
37
81
|
- lib/zammad_api/errors.rb
|
|
38
|
-
- lib/zammad_api/
|
|
39
|
-
- lib/zammad_api/list_all.rb
|
|
40
|
-
- lib/zammad_api/list_base.rb
|
|
41
|
-
- lib/zammad_api/list_search.rb
|
|
42
|
-
- lib/zammad_api/log.rb
|
|
82
|
+
- lib/zammad_api/resource_proxy.rb
|
|
43
83
|
- lib/zammad_api/resources.rb
|
|
44
84
|
- lib/zammad_api/resources/base.rb
|
|
45
85
|
- lib/zammad_api/resources/group.rb
|
|
@@ -50,17 +90,31 @@ files:
|
|
|
50
90
|
- lib/zammad_api/resources/ticket_priority.rb
|
|
51
91
|
- lib/zammad_api/resources/ticket_state.rb
|
|
52
92
|
- lib/zammad_api/resources/user.rb
|
|
93
|
+
- lib/zammad_api/response.rb
|
|
53
94
|
- lib/zammad_api/transport.rb
|
|
54
95
|
- lib/zammad_api/version.rb
|
|
96
|
+
- sig/zammad_api.rbs
|
|
97
|
+
- sig/zammad_api/attribute_access.rbs
|
|
98
|
+
- sig/zammad_api/client.rbs
|
|
99
|
+
- sig/zammad_api/collection.rbs
|
|
100
|
+
- sig/zammad_api/config.rbs
|
|
101
|
+
- sig/zammad_api/deep_copy.rbs
|
|
102
|
+
- sig/zammad_api/errors.rbs
|
|
103
|
+
- sig/zammad_api/resource_proxy.rbs
|
|
104
|
+
- sig/zammad_api/resources/base.rbs
|
|
105
|
+
- sig/zammad_api/resources/resources.rbs
|
|
106
|
+
- sig/zammad_api/response.rbs
|
|
107
|
+
- sig/zammad_api/transport.rbs
|
|
55
108
|
homepage: https://github.com/zammad/zammad-api-client-ruby
|
|
56
109
|
licenses:
|
|
57
110
|
- AGPL-3.0-only
|
|
58
111
|
- MIT
|
|
59
112
|
metadata:
|
|
60
113
|
allowed_push_host: https://rubygems.org
|
|
61
|
-
homepage_uri: https://github.com/zammad/zammad-api-client-ruby
|
|
62
114
|
source_code_uri: https://github.com/zammad/zammad-api-client-ruby
|
|
63
115
|
changelog_uri: https://github.com/zammad/zammad-api-client-ruby/blob/master/CHANGELOG.md
|
|
116
|
+
bug_tracker_uri: https://github.com/zammad/zammad-api-client-ruby/issues
|
|
117
|
+
documentation_uri: https://rubydoc.info/gems/zammad_api/2.0.0.alpha1
|
|
64
118
|
rubygems_mfa_required: 'true'
|
|
65
119
|
rdoc_options: []
|
|
66
120
|
require_paths:
|
|
@@ -69,14 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
69
123
|
requirements:
|
|
70
124
|
- - ">="
|
|
71
125
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: '3.
|
|
126
|
+
version: '3.4'
|
|
73
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
128
|
requirements:
|
|
75
129
|
- - ">="
|
|
76
130
|
- !ruby/object:Gem::Version
|
|
77
131
|
version: '0'
|
|
78
132
|
requirements: []
|
|
79
|
-
rubygems_version:
|
|
133
|
+
rubygems_version: 4.0.20
|
|
80
134
|
specification_version: 4
|
|
81
|
-
summary: Zammad API v1.0
|
|
135
|
+
summary: Ruby client for the Zammad API v1.0.
|
|
82
136
|
test_files: []
|