-
Notifications
You must be signed in to change notification settings - Fork 6
/
DTITCFunctions.m
176 lines (149 loc) · 3.97 KB
/
DTITCFunctions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//
// DTITCFuncations.m
// TheMissingAPI
//
// Created by Oliver Drobnik on 12.04.13.
// Copyright (c) 2013 Drobnik KG. All rights reserved.
//
#import "DTITC.h"
/**
Functions to convert between enum and string representations
*/
#pragma mark - Report Type Conversion
NSString *NSStringFromITCReportType(ITCReportType reportType)
{
switch (reportType)
{
case ITCReportTypeSales:
{
return @"Sales";
}
case ITCReportTypeNewsstand:
{
return @"Newsstand";
}
default:
{
return nil;
}
}
}
ITCReportType reportTypeFromString(NSString *reportTypeString)
{
if ([reportTypeString isEqualToString:@"Sales"] || [reportTypeString isEqualToString:@"S"])
{
return ITCReportTypeSales;
}
else if ([reportTypeString isEqualToString:@"Newsstand"] || [reportTypeString isEqualToString:@"N"])
{
return ITCReportTypeNewsstand;
}
return ITCReportTypeUnknown;
}
#pragma mark - Report Sub Type Conversion
NSString *NSStringFromITCReportSubType(ITCReportSubType reportSubType)
{
switch (reportSubType)
{
case ITCReportSubTypeSummary:
{
return @"Summary";
}
case ITCReportSubTypeDetailed:
{
return @"Detailed";
}
case ITCReportSubTypeOptIn:
{
return @"Opt-In";
}
default:
{
return nil;
}
}
}
ITCReportSubType reportSubTypeFromString(NSString *reportSubTypeString)
{
if ([reportSubTypeString isEqualToString:@"Summary"] || [reportSubTypeString isEqualToString:@"S"])
{
return ITCReportSubTypeSummary;
}
else if ([reportSubTypeString isEqualToString:@"Detailed"] || [reportSubTypeString isEqualToString:@"D"])
{
return ITCReportSubTypeDetailed;
}
else if ([reportSubTypeString isEqualToString:@"Opt-In"] || [reportSubTypeString isEqualToString:@"O"])
{
return ITCReportSubTypeOptIn;
}
return ITCReportSubTypeUnknown;
}
#pragma mark - Report Date Type Conversion
NSString *NSStringFromITCReportDateType(ITCReportDateType reportDateType)
{
switch (reportDateType)
{
case ITCReportDateTypeDaily:
{
return @"Daily";
}
case ITCReportDateTypeWeekly:
{
return @"Weekly";
}
case ITCReportDateTypeMonthly:
{
return @"Monthly";
}
case ITCReportDateTypeYearly:
{
return @"Yearly";
}
default:
{
return nil;
}
}
}
ITCReportDateType reportDateTypeFromString(NSString *reportDateTypeString)
{
if ([reportDateTypeString isEqualToString:@"Daily"] || [reportDateTypeString isEqualToString:@"D"])
{
return ITCReportDateTypeDaily;
}
else if ([reportDateTypeString isEqualToString:@"Weekly"] || [reportDateTypeString isEqualToString:@"W"])
{
return ITCReportDateTypeWeekly;
}
else if ([reportDateTypeString isEqualToString:@"Monthly"] || [reportDateTypeString isEqualToString:@"M"])
{
return ITCReportDateTypeMonthly;
}
else if ([reportDateTypeString isEqualToString:@"Yearly"] || [reportDateTypeString isEqualToString:@"Y"])
{
return ITCReportDateTypeYearly;
}
return ITCReportDateTypeUnknown;
}
#pragma mark - Date Formatting
NSString *NSStringWithDateFormatForITCReportDateType(ITCReportDateType reportDateType)
{
switch (reportDateType)
{
case ITCReportDateTypeDaily:
case ITCReportDateTypeWeekly:
default:
{
return @"yyyyMMdd";
}
case ITCReportDateTypeMonthly:
{
return @"yyyyMM";
}
case ITCReportDateTypeYearly:
{
return @"yyyy";
}
}
}