UNPKG

2.4 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 @"alias": [RNBranchProperty propertyWithSetterSelector:@selector(setAlias:) type:NSString.class]
32 };
33 });
34
35 return _eventProperties;
36}
37
38- (instancetype)initWithName:(NSString *)eventName map:(NSDictionary *)map
39{
40 self = [self initWithName:eventName];
41 if (self) {
42 [self setSupportedPropertiesWithMap:map];
43 }
44 return self;
45}
46
47- (void)setRevenueWithString:(NSString *)revenue
48{
49 self.revenue = [NSDecimalNumber decimalNumberWithString:revenue];
50}
51
52- (void)setShippingWithString:(NSString *)shipping
53{
54 self.shipping = [NSDecimalNumber decimalNumberWithString:shipping];
55}
56
57- (void)setTaxWithString:(NSString *)tax
58{
59 self.tax = [NSDecimalNumber decimalNumberWithString:tax];
60}
61
62@end