This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func readHourlyTotalStepCount() { | |
| guard let stepCountType = HKObjectType.quantityType(forIdentifier: .stepCount) else { | |
| fatalError("*** Unable to get the step count type ***") | |
| } | |
| var interval = DateComponents() | |
| interval.hour = 1 | |
| let calendar = Calendar.current | |
| let anchorDate = calendar.date(bySettingHour: 0, minute: 55, second: 0, of: Date()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func readTotalStepCount() { | |
| guard let stepCountType = HKObjectType.quantityType(forIdentifier: .stepCount) else { | |
| fatalError("*** Unable to get the step count type ***") | |
| } | |
| let query = HKStatisticsQuery.init(quantityType: stepCountType, | |
| quantitySamplePredicate: get24hPredicate(), | |
| options: [HKStatisticsOptions.cumulativeSum, HKStatisticsOptions.separateBySource]) { (query, results, error) in | |
| let totalStepCount = results?.sumQuantity()!.doubleValue(for: HKUnit.count()) | |
| print("Total step count: \(totalStepCount ?? 0)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import HealthKit | |
| struct ContentView: View { | |
| @EnvironmentObject var healthStore: HKHealthStore | |
| var body: some View { | |
| VStack { | |
| Image(systemName: "globe") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import HealthKit | |
| @main | |
| struct HealthkitIntegrationApp: App { | |
| private let healthStore: HKHealthStore | |
| init() { | |
| guard HKHealthStore.isHealthDataAvailable() else { fatalError("This app requires a device that supports HealthKit") } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.post("/refund-separate", async (req, res) => { | |
| const refund = await stripe.refunds.create({ | |
| charge: "<charge id>", | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.post("/refund-destination", async (req, res) => { | |
| const refund = await stripe.refunds.create({ | |
| charge: "<charge id>", | |
| reverse_transfer: true, | |
| refund_application_fee: true, | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.post("/refund-direct", async (req, res) => { | |
| const refund = await stripe.refunds.create( | |
| { | |
| charge: "<charge id>", | |
| refund_application_fee: true, | |
| }, | |
| { | |
| stripeAccount: "<connected account id>", | |
| } | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const API_URL = 'http://localhost:8000'; | |
| const refund = async () => { | |
| const response = await fetch(`${API_URL}/refund`); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.post("/refund", async (req, res) => { | |
| const refund = await stripe.refunds.create({ | |
| payment_intent: 'pi_Aabcxyz01aDfoo' | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.post("/transfer", async (req, res) => { | |
| const transfer = await stripe.transfers.create({ | |
| amount: 2000, | |
| currency: "sek", | |
| destination: "CONNECTED_STRIPE_ACCOUNT_ID", | |
| transfer_group: "your first group", | |
| }); | |
| }); |
NewerOlder