use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-accounts")]
use objc2_accounts::*;
use objc2_foundation::*;
use crate::*;
#[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!(
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>;
}
);