1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-accounts")]
use objc2_accounts::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SLRequestMethod(pub NSInteger);
impl SLRequestMethod {
    #[doc(alias = "SLRequestMethodGET")]
    pub const GET: Self = Self(0);
    #[doc(alias = "SLRequestMethodPOST")]
    pub const POST: Self = Self(1);
    #[doc(alias = "SLRequestMethodDELETE")]
    pub const DELETE: Self = Self(2);
    #[doc(alias = "SLRequestMethodPUT")]
    pub const PUT: Self = Self(3);
}

unsafe impl Encode for SLRequestMethod {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for SLRequestMethod {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "block2")]
pub type SLRequestHandler =
    *mut block2::Block<dyn Fn(*mut NSData, *mut NSHTTPURLResponse, *mut NSError)>;

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SLRequest;

    unsafe impl ClassType for SLRequest {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for SLRequest {}

extern_methods!(
    unsafe impl SLRequest {
        #[method_id(@__retain_semantics Other requestForServiceType:requestMethod:URL:parameters:)]
        pub unsafe fn requestForServiceType_requestMethod_URL_parameters(
            service_type: Option<&NSString>,
            request_method: SLRequestMethod,
            url: Option<&NSURL>,
            parameters: Option<&NSDictionary>,
        ) -> Option<Retained<SLRequest>>;

        #[cfg(feature = "objc2-accounts")]
        #[method_id(@__retain_semantics Other account)]
        pub unsafe fn account(&self) -> Option<Retained<ACAccount>>;

        #[cfg(feature = "objc2-accounts")]
        #[method(setAccount:)]
        pub unsafe fn setAccount(&self, account: Option<&ACAccount>);

        #[method(requestMethod)]
        pub unsafe fn requestMethod(&self) -> SLRequestMethod;

        #[method_id(@__retain_semantics Other URL)]
        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;

        #[method_id(@__retain_semantics Other parameters)]
        pub unsafe fn parameters(&self) -> Option<Retained<NSDictionary>>;

        #[method(addMultipartData:withName:type:filename:)]
        pub unsafe fn addMultipartData_withName_type_filename(
            &self,
            data: Option<&NSData>,
            name: Option<&NSString>,
            r#type: Option<&NSString>,
            filename: Option<&NSString>,
        );

        #[method(addMultipartData:withName:type:)]
        pub unsafe fn addMultipartData_withName_type(
            &self,
            data: Option<&NSData>,
            name: Option<&NSString>,
            r#type: Option<&NSString>,
        );

        #[method_id(@__retain_semantics Other preparedURLRequest)]
        pub unsafe fn preparedURLRequest(&self) -> Option<Retained<NSURLRequest>>;

        #[cfg(feature = "block2")]
        #[method(performRequestWithHandler:)]
        pub unsafe fn performRequestWithHandler(&self, handler: SLRequestHandler);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl SLRequest {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);