Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

1 řádek
4.9 KiB

  1. {"kind":"symbol","metadata":{"role":"symbol","title":"sendToServer()","modules":[{"name":"Fueling"}],"roleHeading":"Instance Method","fragments":[{"kind":"keyword","text":"func"},{"text":" ","kind":"text"},{"kind":"identifier","text":"sendToServer"},{"text":"() ","kind":"text"},{"kind":"keyword","text":"async"}],"symbolKind":"method","externalID":"s:7Fueling15CoreDataManagerC12sendToServeryyYaF"},"primaryContentSections":[{"kind":"declarations","declarations":[{"tokens":[{"kind":"attribute","text":"@"},{"preciseIdentifier":"s:ScM","text":"MainActor","kind":"attribute"},{"kind":"text","text":" "},{"kind":"keyword","text":"func"},{"text":" ","kind":"text"},{"kind":"identifier","text":"sendToServer"},{"text":"() ","kind":"text"},{"text":"async","kind":"keyword"}],"platforms":["iOS"],"languages":["swift"]}]},{"content":[{"level":2,"text":"Discussion","type":"heading","anchor":"discussion"},{"code":["func sendToServer() async {"," print(\"Trying to send\")"," let encoder = JSONEncoder()"," encoder.dateEncodingStrategy = .iso8601"," encoder.outputFormatting = .prettyPrinted",""," do {"," let jsonData = try encoder.encode(Array(fuelingsArray))"," let url = URL(string: \"https:\/\/fueling.prelub.com\/api\/v2\/fuel-entries\")!"," var request = URLRequest(url: url)"," request.httpMethod = \"POST\""," request.httpBody = jsonData"," request.setValue(\"application\/json\", forHTTPHeaderField: \"Content-Type\")"," "," let (_, response) = try await URLSession.shared.data(for: request)"," guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else {"," self.alertTitle = \"Server Error\""," self.alertMessage = \"Failed to send data. Please try again later.\""," self.isShowingAlert = true"," self.isDataSendToServerTestVariable = false"," print(\"Fail data send from sendToServer_1\\(response)\")"," return"," }",""," self.isDataSendToServerTestVariable = true"," self.deleteData()"," self.alertTitle = \"Success\""," self.alertMessage = \"Work order data successfully transferred to server.\""," self.isShowingAlert = true"," print(\"Success data send from sendToServer\")"," } catch {"," self.alertTitle = \"Error\""," self.alertMessage = \"An error occurred while sending data: \\(error.localizedDescription)\""," self.isShowingAlert = true"," self.isDataSendToServerTestVariable = false"," print(\"Fail data send from sendToServer_2 : \\(error.localizedDescription)\")"," }","}"],"type":"codeListing","syntax":"swift"}],"kind":"content"}],"sections":[],"hierarchy":{"paths":[["doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling","doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/CoreDataManager"]]},"variants":[{"traits":[{"interfaceLanguage":"swift"}],"paths":["\/documentation\/fueling\/coredatamanager\/sendtoserver()"]}],"identifier":{"url":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/CoreDataManager\/sendToServer()","interfaceLanguage":"swift"},"schemaVersion":{"patch":0,"major":0,"minor":3},"abstract":[{"type":"text","text":"Sends fueling data to the server."}],"references":{"doc://rpm.com.production.Scanner/documentation/Fueling":{"kind":"symbol","url":"\/documentation\/fueling","title":"Fueling","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling","abstract":[{"type":"text","text":"The Scanner app is designed to facilitate secure and efficient fuel management operations, primarily focusing on user authentication, fuel data collection, and network communication. The app includes several key features to ensure seamless and reliable interactions between users and the backend systems, leveraging technologies like WebSockets, Core Data, and biometric authentication."}],"type":"topic","role":"collection"},"doc://rpm.com.production.Scanner/documentation/Fueling/CoreDataManager/sendToServer()":{"kind":"symbol","abstract":[{"type":"text","text":"Sends fueling data to the server."}],"role":"symbol","title":"sendToServer()","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/CoreDataManager\/sendToServer()","fragments":[{"text":"func","kind":"keyword"},{"kind":"text","text":" "},{"text":"sendToServer","kind":"identifier"},{"text":"() ","kind":"text"},{"text":"async","kind":"keyword"}],"url":"\/documentation\/fueling\/coredatamanager\/sendtoserver()","type":"topic"},"doc://rpm.com.production.Scanner/documentation/Fueling/CoreDataManager":{"fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"text":"CoreDataManager","kind":"identifier"}],"type":"topic","identifier":"doc:\/\/rpm.com.production.Scanner\/documentation\/Fueling\/CoreDataManager","kind":"symbol","title":"CoreDataManager","abstract":[],"navigatorTitle":[{"text":"CoreDataManager","kind":"identifier"}],"url":"\/documentation\/fueling\/coredatamanager","role":"symbol"}}}