• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tylernathanreed / jira-client-php / 13857440588

14 Mar 2025 01:18PM UTC coverage: 70.825% (-0.06%) from 70.885%
13857440588

push

github

tylernathanreed
~ Fixed nested objects in test examples

9 of 9 new or added lines in 1 file covered. (100.0%)

524 existing lines in 407 files now uncovered.

4826 of 6814 relevant lines covered (70.82%)

8.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.19
/src/Operations/Myself.php
1
<?php
2

3
namespace Jira\Client\Operations;
4

5
use Jira\Client\Client;
6
use Jira\Client\Schema;
7

8
/** @phpstan-require-extends Client */
9
trait Myself
10
{
11
    /**
12
     * Returns the value of a preference of the current user
13
     * 
14
     * Note that these keys are deprecated:
15
     * 
16
     *  - *jira.user.locale* The locale of the user.
17
     * By default this is not set and the user takes the locale of the instance
18
     *  - *jira.user.timezone* The time zone of the user.
19
     * By default this is not set and the user takes the timezone of the instance
20
     * 
21
     * These system preferences keys will be deprecated by 15/07/2024.
22
     * You can still retrieve these keys, but it will not have any impact on Notification behaviour
23
     * 
24
     *  - *user.notifications.watcher* Whether the user gets notified when they are watcher
25
     *  - *user.notifications.assignee* Whether the user gets notified when they are assignee
26
     *  - *user.notifications.reporter* Whether the user gets notified when they are reporter
27
     *  - *user.notifications.mentions* Whether the user gets notified when they are mentions
28
     * 
29
     * Use " Update a user profile" from the user management REST API to manage timezone and locale instead
30
     * 
31
     * **"Permissions" required:** Permission to access Jira.
32
     * 
33
     * @link https://developer.atlassian.com/cloud/admin/user-management/rest/#api-users-account-id-manage-profile-patch
34
     * 
35
     * @param string $key The key of the preference.
36
     */
UNCOV
37
    public function getPreference(
×
38
        string $key,
39
    ): true {
40
        return $this->call(
×
41
            uri: '/rest/api/3/mypreferences',
×
42
            method: 'get',
×
43
            query: compact('key'),
×
44
            success: 200,
×
45
            schema: true,
×
46
        );
×
47
    }
48

49
    /**
50
     * Creates a preference for the user or updates a preference's value by sending a plain text string.
51
     * For example, `false`.
52
     * An arbitrary preference can be created with the value containing up to 255 characters.
53
     * In addition, the following keys define system preferences that can be set or created:
54
     * 
55
     *  - *user.notifications.mimetype* The mime type used in notifications sent to the user.
56
     * Defaults to `html`
57
     *  - *user.default.share.private* Whether new " filters" are set to private.
58
     * Defaults to `true`
59
     *  - *user.keyboard.shortcuts.disabled* Whether keyboard shortcuts are disabled.
60
     * Defaults to `false`
61
     *  - *user.autowatch.disabled* Whether the user automatically watches issues they create or add a comment to.
62
     * By default, not set: the user takes the instance autowatch setting
63
     *  - *user.notifiy.own.changes* Whether the user gets notified of their own changes
64
     * 
65
     * Note that these keys are deprecated:
66
     * 
67
     *  - *jira.user.locale* The locale of the user.
68
     * By default, not set.
69
     * The user takes the instance locale
70
     *  - *jira.user.timezone* The time zone of the user.
71
     * By default, not set.
72
     * The user takes the instance timezone
73
     * 
74
     * These system preferences keys will be deprecated by 15/07/2024.
75
     * You can still use these keys to create arbitrary preferences, but it will not have any impact on Notification behaviour
76
     * 
77
     *  - *user.notifications.watcher* Whether the user gets notified when they are watcher
78
     *  - *user.notifications.assignee* Whether the user gets notified when they are assignee
79
     *  - *user.notifications.reporter* Whether the user gets notified when they are reporter
80
     *  - *user.notifications.mentions* Whether the user gets notified when they are mentions
81
     * 
82
     * Use " Update a user profile" from the user management REST API to manage timezone and locale instead
83
     * 
84
     * **"Permissions" required:** Permission to access Jira.
85
     * 
86
     * @link https://confluence.atlassian.com/x/eQiiLQ
87
     * @link https://developer.atlassian.com/cloud/admin/user-management/rest/#api-users-account-id-manage-profile-patch
88
     * 
89
     * @param string $key The key of the preference.
90
     *                    The maximum length is 255 characters.
91
     */
92
    public function setPreference(
1✔
93
        string $key,
94
    ): true {
95
        return $this->call(
1✔
96
            uri: '/rest/api/3/mypreferences',
1✔
97
            method: 'put',
1✔
98
            query: compact('key'),
1✔
99
            success: 204,
1✔
100
            schema: true,
1✔
101
        );
1✔
102
    }
103

104
    /**
105
     * Deletes a preference of the user, which restores the default value of system defined settings
106
     * 
107
     * Note that these keys are deprecated:
108
     * 
109
     *  - *jira.user.locale* The locale of the user.
110
     * By default, not set.
111
     * The user takes the instance locale
112
     *  - *jira.user.timezone* The time zone of the user.
113
     * By default, not set.
114
     * The user takes the instance timezone
115
     * 
116
     * Use " Update a user profile" from the user management REST API to manage timezone and locale instead
117
     * 
118
     * **"Permissions" required:** Permission to access Jira.
119
     * 
120
     * @link https://developer.atlassian.com/cloud/admin/user-management/rest/#api-users-account-id-manage-profile-patch
121
     * 
122
     * @param string $key The key of the preference.
123
     */
124
    public function removePreference(
1✔
125
        string $key,
126
    ): true {
127
        return $this->call(
1✔
128
            uri: '/rest/api/3/mypreferences',
1✔
129
            method: 'delete',
1✔
130
            query: compact('key'),
1✔
131
            success: 204,
1✔
132
            schema: true,
1✔
133
        );
1✔
134
    }
135

136
    /**
137
     * Returns the locale for the user
138
     * 
139
     * If the user has no language preference set (which is the default setting) or this resource is accessed anonymous, the browser locale detected by Jira is returned.
140
     * Jira detects the browser locale using the *Accept-Language* header in the request.
141
     * However, if this doesn't match a locale available Jira, the site default locale is returned
142
     * 
143
     * This operation can be accessed anonymously
144
     * 
145
     * **"Permissions" required:** None.
146
     */
147
    public function getLocale(): Schema\Locale
1✔
148
    {
149
        return $this->call(
1✔
150
            uri: '/rest/api/3/mypreferences/locale',
1✔
151
            method: 'get',
1✔
152
            success: 200,
1✔
153
            schema: Schema\Locale::class,
1✔
154
        );
1✔
155
    }
156

157
    /**
158
     * Deprecated, use " Update a user profile" from the user management REST API instead
159
     * 
160
     * Sets the locale of the user.
161
     * The locale must be one supported by the instance of Jira
162
     * 
163
     * **"Permissions" required:** Permission to access Jira.
164
     * 
165
     * @link https://developer.atlassian.com/cloud/admin/user-management/rest/#api-users-account-id-manage-profile-patch
166
     */
167
    public function setLocale(
1✔
168
        Schema\Locale $request,
169
    ): true {
170
        return $this->call(
1✔
171
            uri: '/rest/api/3/mypreferences/locale',
1✔
172
            method: 'put',
1✔
173
            body: $request,
1✔
174
            success: 204,
1✔
175
            schema: true,
1✔
176
        );
1✔
177
    }
178

179
    /**
180
     * Deprecated, use " Update a user profile" from the user management REST API instead
181
     * 
182
     * Deletes the locale of the user, which restores the default setting
183
     * 
184
     * **"Permissions" required:** Permission to access Jira.
185
     * 
186
     * @link https://developer.atlassian.com/cloud/admin/user-management/rest/#api-users-account-id-manage-profile-patch
187
     */
188
    public function deleteLocale(): true
1✔
189
    {
190
        return $this->call(
1✔
191
            uri: '/rest/api/3/mypreferences/locale',
1✔
192
            method: 'delete',
1✔
193
            success: 204,
1✔
194
            schema: true,
1✔
195
        );
1✔
196
    }
197

198
    /**
199
     * Returns details for the current user
200
     * 
201
     * **"Permissions" required:** Permission to access Jira.
202
     * 
203
     * @param string $expand Use "expand" to include additional information about user in the response.
204
     *                       This parameter accepts a comma-separated list.
205
     *                       Expand options include:
206
     *                        - `groups` Returns all groups, including nested groups, the user belongs to
207
     *                        - `applicationRoles` Returns the application roles the user is assigned to.
208
     */
209
    public function getCurrentUser(
1✔
210
        ?string $expand = null,
211
    ): Schema\User {
212
        return $this->call(
1✔
213
            uri: '/rest/api/3/myself',
1✔
214
            method: 'get',
1✔
215
            query: compact('expand'),
1✔
216
            success: 200,
1✔
217
            schema: Schema\User::class,
1✔
218
        );
1✔
219
    }
220
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc