<commit_before>//
//  TempBasalNightscoutTreatment.swift
//  RileyLink
//
//  Created by <NAME> on 4/18/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public class TempBasalNightscoutTreatment: NightscoutTreatment {
    
    public enum RateType: String {
        case Absolute = "absolute"
        case Percentage = "percentage"
    }
    
    
    let rate: Double
    let absolute: Double?
    let temp: RateType
    let duration: Int
    
    public init(timestamp: Date, enteredBy: String, temp: RateType, rate: Double, absolute: Double?, duration: Int, id: String? = nil) {
        self.rate = rate
        self.absolute = absolute
        self.temp = temp
        self.duration = duration
        
        // Commenting out usage of surrogate ID until supported by Nightscout
        super.init(timestamp: timestamp, enteredBy: enteredBy, /*id: id,*/ eventType: "Temp Basal")
    }
    
    override public var dictionaryRepresentation: [String: Any] {
        var rval = super.dictionaryRepresentation
        rval["temp"] = temp.rawValue
        rval["rate"] = rate
        if let absolute = absolute {
            rval["absolute"] = absolute
        }
        rval["duration"] = duration
        return rval
    }
}<commit_msg>Upload delivered volume for temp basals to Nightscout (#542)<commit_after>//
//  TempBasalNightscoutTreatment.swift
//  RileyLink
//
//  Created by <NAME> on 4/18/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public class TempBasalNightscoutTreatment: NightscoutTreatment {
    
    public enum RateType: String {
        case Absolute = "absolute"
        case Percentage = "percentage"
    }
    
    
    let rate: Double
    let amount: Double?
    let absolute: Double?
    let temp: RateType
    let duration: Int
    
    public init(timestamp: Date, enteredBy: String, temp: RateType, rate: Double, absolute: Double?, duration: Int, amount: Double? = nil, id: String? = nil) {
        self.rate = rate
        self.absolute = absolute
        self.temp = temp
        self.duration = duration
        self.amount = amount
        
        // Commenting out usage of surrogate ID until supported by Nightscout
        super.init(timestamp: timestamp, enteredBy: enteredBy, /*id: id,*/ eventType: "Temp Basal")
    }
    
    override public var dictionaryRepresentation: [String: Any] {
        var rval = super.dictionaryRepresentation
        rval["temp"] = temp.rawValue
        rval["rate"] = rate
        rval["absolute"] = absolute
        rval["duration"] = duration
        rval["amount"] = amount
        return rval
    }
}
{'fraction_non_alphanumeric': 0.09818043972706596, 'fraction_numerical': 0.00796057619408643, 'mean_word_length': 2.392030848329049, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4669687', 'n_tokens_mistral': 778, 'n_tokens_neox': 728, 'n_words': 232}