@@ -8,6 +8,8 @@ use crate::{profile_api::ProfilesResponse, AppStoreConnectClient, Result};
8
8
use serde:: { Deserialize , Serialize } ;
9
9
10
10
const APPLE_BUNDLE_IDS_URL : & str = "https://api.appstoreconnect.apple.com/v1/bundleIds" ;
11
+ const APPLE_BUNDLE_CAPABILITIES_URL : & str =
12
+ "https://api.appstoreconnect.apple.com/v1/bundleIdCapabilities" ;
11
13
12
14
impl AppStoreConnectClient {
13
15
pub fn register_bundle_id ( & self , identifier : & str , name : & str ) -> Result < BundleIdResponse > {
@@ -72,6 +74,38 @@ impl AppStoreConnectClient {
72
74
Ok ( self . send_request ( req) ?. json ( ) ?)
73
75
}
74
76
77
+ pub fn enable_bundle_id_capability (
78
+ & self ,
79
+ id : & str ,
80
+ capability : BundleIdCapabilityCreateRequestDataAttributes ,
81
+ ) -> Result < ( ) > {
82
+ let token = self . get_token ( ) ?;
83
+
84
+ let body = BundleIdCapabilityCreateRequest {
85
+ data : BundleIdCapabilityCreateRequestData {
86
+ attributes : capability,
87
+ relationships : BundleIdCapabilityCreateRequestDataRelationships {
88
+ bundle_id : BundleIdCapabilityCreateRequestDataRelationshipBundleId {
89
+ data : BundleIdCapabilityCreateRequestDataRelationshipBundleIdData {
90
+ id : id. to_string ( ) ,
91
+ r#type : "bundleIds" . to_string ( ) ,
92
+ } ,
93
+ } ,
94
+ } ,
95
+ r#type : "bundleIdCapabilities" . to_string ( ) ,
96
+ } ,
97
+ } ;
98
+
99
+ let req = self
100
+ . client
101
+ . post ( APPLE_BUNDLE_CAPABILITIES_URL )
102
+ . bearer_auth ( token)
103
+ . header ( "Accept" , "application/json" )
104
+ . json ( & body) ;
105
+ self . send_request ( req) ?;
106
+ Ok ( ( ) )
107
+ }
108
+
75
109
pub fn delete_bundle_id ( & self , id : & str ) -> Result < ( ) > {
76
110
let token = self . get_token ( ) ?;
77
111
let req = self
@@ -159,8 +193,47 @@ pub struct BundleCapability {
159
193
pub id : String ,
160
194
}
161
195
162
- #[ derive( Debug , Deserialize ) ]
196
+ #[ derive( Debug , Deserialize , Serialize ) ]
163
197
#[ serde( rename_all = "camelCase" ) ]
164
198
pub struct BundleCapabilityAttributes {
165
199
pub capability_type : String ,
166
200
}
201
+
202
+ #[ derive( Debug , Serialize ) ]
203
+ #[ serde( rename_all = "camelCase" ) ]
204
+ pub struct BundleIdCapabilityCreateRequest {
205
+ data : BundleIdCapabilityCreateRequestData ,
206
+ }
207
+
208
+ #[ derive( Debug , Serialize ) ]
209
+ #[ serde( rename_all = "camelCase" ) ]
210
+ pub struct BundleIdCapabilityCreateRequestData {
211
+ attributes : BundleIdCapabilityCreateRequestDataAttributes ,
212
+ relationships : BundleIdCapabilityCreateRequestDataRelationships ,
213
+ r#type : String ,
214
+ }
215
+
216
+ #[ derive( Debug , Serialize ) ]
217
+ #[ serde( rename_all = "camelCase" ) ]
218
+ pub struct BundleIdCapabilityCreateRequestDataAttributes {
219
+ pub capability_type : String ,
220
+ }
221
+
222
+ #[ derive( Debug , Serialize ) ]
223
+ #[ serde( rename_all = "camelCase" ) ]
224
+ pub struct BundleIdCapabilityCreateRequestDataRelationships {
225
+ bundle_id : BundleIdCapabilityCreateRequestDataRelationshipBundleId ,
226
+ }
227
+
228
+ #[ derive( Debug , Serialize ) ]
229
+ #[ serde( rename_all = "camelCase" ) ]
230
+ pub struct BundleIdCapabilityCreateRequestDataRelationshipBundleId {
231
+ data : BundleIdCapabilityCreateRequestDataRelationshipBundleIdData ,
232
+ }
233
+
234
+ #[ derive( Debug , Serialize ) ]
235
+ #[ serde( rename_all = "camelCase" ) ]
236
+ pub struct BundleIdCapabilityCreateRequestDataRelationshipBundleIdData {
237
+ id : String ,
238
+ r#type : String ,
239
+ }
0 commit comments