UNPKG

2.29 kBPlain TextView Raw
1//
2// BranchEvent+RNBranch.m
3// Branch-SDK
4//
5// Created by Jimmy Dee on 11/28/17.
6//
7
8#import "BranchEvent+RNBranch.h"
9#import "NSObject+RNBranch.h"
10#import "RNBranchProperty.h"
11
12@implementation BranchEvent(RNBranch)
13
14+ (NSDictionary<NSString *,RNBranchProperty *> *)supportedProperties
15{
16 static NSDictionary<NSString *, RNBranchProperty *> *_eventProperties;
17 static dispatch_once_t once = 0;
18 dispatch_once(&once, ^{
19 _eventProperties =
20 @{
21 @"transactionID": [RNBranchProperty propertyWithSetterSelector:@selector(setTransactionID:) type:NSString.class],
22 @"currency": [RNBranchProperty propertyWithSetterSelector:@selector(setCurrency:) type:NSString.class],
23 @"revenue": [RNBranchProperty propertyWithSetterSelector:@selector(setRevenueWithString:) type:NSString.class],
24 @"shipping": [RNBranchProperty propertyWithSetterSelector:@selector(setShippingWithString:) type:NSString.class],
25 @"tax": [RNBranchProperty propertyWithSetterSelector:@selector(setTaxWithString:) type:NSString.class],
26 @"coupon": [RNBranchProperty propertyWithSetterSelector:@selector(setCoupon:) type:NSString.class],
27 @"affiliation": [RNBranchProperty propertyWithSetterSelector:@selector(setAffiliation:) type:NSString.class],
28 @"description": [RNBranchProperty propertyWithSetterSelector:@selector(setEventDescription:) type:NSString.class],
29 @"searchQuery": [RNBranchProperty propertyWithSetterSelector:@selector(setSearchQuery:) type:NSString.class],
30 @"customData": [RNBranchProperty propertyWithSetterSelector:@selector(setCustomData:) type:NSDictionary.class]
31 };
32 });
33
34 return _eventProperties;
35}
36
37- (instancetype)initWithName:(NSString *)eventName map:(NSDictionary *)map
38{
39 self = [self initWithName:eventName];
40 if (self) {
41 [self setSupportedPropertiesWithMap:map];
42 }
43 return self;
44}
45
46- (void)setRevenueWithString:(NSString *)revenue
47{
48 self.revenue = [NSDecimalNumber decimalNumberWithString:revenue];
49}
50
51- (void)setShippingWithString:(NSString *)shipping
52{
53 self.shipping = [NSDecimalNumber decimalNumberWithString:shipping];
54}
55
56- (void)setTaxWithString:(NSString *)tax
57{
58 self.tax = [NSDecimalNumber decimalNumberWithString:tax];
59}
60
61@end