-
Notifications
You must be signed in to change notification settings - Fork 0
/
VenmoTransaction.cs
executable file
·134 lines (128 loc) · 4.32 KB
/
VenmoTransaction.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VenmoWrapper
{
/// <summary>
/// An object containing all the data provided by Venmo for a transaction.
/// N.B: fee and refund are of type Nullable<double>, not just double.
/// </summary>
public class VenmoTransaction
{
public string id { get; set; }
public string status { get; set; }
public string note { get; set; }
public double amount { get; set; }
public string formattedAmount
{
get
{
return amount.ToString("N2");
}
}
public string action { get; set; }
public string date_created { get; set; }
public string date_completed { get; set; }
public string audience { get; set; }
public VenmoTarget target { get; set; }
public VenmoUser actor { get; set; }
public double? fee { get; set; }
public double? refund { get; set; }
public string medium { get; set; }
/// <summary>
/// Accessor which returns the payment type of this particular transaction.
/// </summary>
public string paymentType
{
get
{
bool userInitiated = actor.id.Equals(VenmoHelper.currentAuth.currentUser.id) ? true : false;
bool payment = "pay".Equals(action);
return userInitiated ? payment ? "userpay" : "usercharge" : payment ? "otherpay" : "othercharge";
//The hilarious line above is functionally identical to the below.
/*
if (userInitiated)
{
if (payment)
{
return "userpay";
}
else
{
return "usercharge";
}
}
else
{
if (payment)
{
return "otherpay";
}
else
{
return "othercharge";
}
}
* */
}
}
/// <summary>
/// Accessor which provides a human-readable string describing what took place in this transaction.
/// </summary>
public string transactionString
{
get
{
string actorname = actor.display_name;
string targetname;
switch (target.type)
{
case "phone":
targetname = target.phone;
break;
case "email":
targetname = target.email;
break;
case "user":
targetname = target.user.display_name;
break;
default:
targetname = "someone";
break;
}
switch (paymentType)
{
case "userpay":
return "You paid " + targetname + ".";
case "usercharge":
return "You charged " + targetname + ".";
case "otherpay":
return actorname + " paid you.";
case "othercharge":
return actorname + " charged you.";
default:
return "Something Happened.";
}
}
}
public string amountString
{
get
{
switch (paymentType)
{
case "userpay":
case "othercharge":
return "-$" + formattedAmount;
case "usercharge":
case "otherpay":
return "+$" + formattedAmount;
default:
return formattedAmount;
}
}
}
}
}