@@ -13,7 +13,7 @@ class UserStatistics extends Model
13
13
/**
14
14
* Get the user's statistics.
15
15
*
16
- * @return Statistic
16
+ * @return Array of Statistics.
17
17
*/
18
18
public function getStatistics ()
19
19
{
@@ -27,6 +27,9 @@ public function getStatistics()
27
27
/**
28
28
* Get a statistic.
29
29
*
30
+ * @param $typeCode code of the category type.
31
+ * @param $categoryCode code of the statistical category.
32
+ *
30
33
* @return Statistic.
31
34
*/
32
35
public function getStatistic ($ typeCode ,$ categoryCode )
@@ -42,10 +45,18 @@ public function getStatistic($typeCode,$categoryCode)
42
45
}
43
46
44
47
/**
45
- * Add a user statistic.
48
+ * Add a user statistic with no regard to existing Types and Categories.
49
+ *
50
+ * @param string $typeCode code of the category type.
51
+ * @param string $typeDesc description of the category type.
52
+ * @param string $categoryCode code of the statistical category.
53
+ * @param string $categoryDesc description of the statistical category.
54
+ * @param string $note free text description of the statistic.
55
+ * @param string $segment_type (Internal|External)
46
56
*
57
+ * @return Statistic
47
58
*/
48
- public function addStatistic ($ typeCode ,$ typeDesc ,$ categoryCode ,$ categoryDesc ,$ note ,$ segment_type )
59
+ public function addStatisticRaw ($ typeCode ,$ typeDesc ,$ categoryCode ,$ categoryDesc ,$ note ,$ segment_type )
49
60
{
50
61
# Create the new statistic object
51
62
$ stat_obj = (object ) [
@@ -61,16 +72,59 @@ public function addStatistic($typeCode,$typeDesc,$categoryCode,$categoryDesc,$no
61
72
'segment_type ' => $ segment_type ,
62
73
];
63
74
75
+
76
+ //* TODO HERE *//
77
+
64
78
# Add the object to the user
65
79
$ this ->data ->user_statistic [] = $ stat_obj ;
80
+
81
+ /* Not Sure this is quite right or needed. */
82
+ return Statistic::make ($ this ->client ,$ stat_obj );
83
+ }
84
+
85
+ /**
86
+ * Add a user statistic based upon existing Types and Categories.
87
+ *
88
+ * @param string $typeCode code of the category type.
89
+ * @param string $categoryCode code of the statistical category.
90
+ *
91
+ * @return Statistic
92
+ */
93
+ public function addStatistic ($ typeCode ,$ categoryCode )
94
+ {
95
+ //* TODO HERE *//
96
+
97
+ /* Logic: */
98
+ /* Lookup both $typeCode and $categoryCode in codetable */
99
+ /* Obtain information (code/description) from both code tables. */
100
+ /* If found and ok, add the statistic to the user */
101
+
102
+ /* Code Tables used:
103
+ Code Table; UserStatisticalTypes
104
+ Code Table: UserStatCategories
105
+ */
106
+
107
+ /* Seems to be an issue with # of categoryCodes that can be pulled at once (max:10) */
108
+ /* But performing via curl returns all (???). */
109
+ /* May need to open a case to allow resumption on pulling code tables regarding 'limit' and 'offset'? */
66
110
}
67
111
68
112
/**
69
113
* Delete a user statistic.
70
114
*
115
+ * @param string $typeCode code of the category type.
116
+ * @param string $categoryCode code of the statistical category.
71
117
*/
72
118
public function removeStatistic ($ typeCode ,$ categoryCode )
73
119
{
120
+ foreach ($ this ->data ->user_statistic as $ statistic ) {
121
+ if (($ statistic ->category_type ->value == $ typeCode ) && ($ statistic ->statistic_category ->value == $ categoryCode )) {
122
+
123
+ //* TODO HERE *//
124
+
125
+ return ;
126
+ }
127
+ }
74
128
}
75
129
76
130
/**
@@ -79,6 +133,11 @@ public function removeStatistic($typeCode,$categoryCode)
79
133
*/
80
134
public function updateStatistic ($ fromTypeCode ,$ fromCategoryCode ,$ toTypeCode ,$ toCategoryCode )
81
135
{
136
+
137
+ //* TODO HERE *//
138
+
139
+ /* Remove "from" statistic, then add "to" statistic */
140
+
82
141
$ this ->removeStatistic ($ fromTypeCode ,$ categoryCode );
83
142
$ this ->addStatistic ($ toTypeCode ,$ toCategoryCode );
84
143
}
0 commit comments