-
Notifications
You must be signed in to change notification settings - Fork 22
/
NoteAttachmentMasterCardAction.cs
199 lines (167 loc) · 8.22 KB
/
NoteAttachmentMasterCardAction.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using Bunq.Sdk.Context;
using Bunq.Sdk.Http;
using Bunq.Sdk.Json;
using Bunq.Sdk.Model.Core;
using Bunq.Sdk.Model.Generated.Object;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Text;
using System;
namespace Bunq.Sdk.Model.Generated.Endpoint
{
/// <summary>
/// Used to manage attachment notes.
/// </summary>
public class NoteAttachmentMasterCardAction : BunqModel
{
/// <summary>
/// Endpoint constants.
/// </summary>
protected const string ENDPOINT_URL_CREATE = "user/{0}/monetary-account/{1}/mastercard-action/{2}/note-attachment";
protected const string ENDPOINT_URL_UPDATE = "user/{0}/monetary-account/{1}/mastercard-action/{2}/note-attachment/{3}";
protected const string ENDPOINT_URL_DELETE = "user/{0}/monetary-account/{1}/mastercard-action/{2}/note-attachment/{3}";
protected const string ENDPOINT_URL_LISTING = "user/{0}/monetary-account/{1}/mastercard-action/{2}/note-attachment";
protected const string ENDPOINT_URL_READ = "user/{0}/monetary-account/{1}/mastercard-action/{2}/note-attachment/{3}";
/// <summary>
/// Field constants.
/// </summary>
public const string FIELD_DESCRIPTION = "description";
public const string FIELD_ATTACHMENT_ID = "attachment_id";
/// <summary>
/// Object type.
/// </summary>
private const string OBJECT_TYPE_GET = "NoteAttachment";
/// <summary>
/// Optional description of the attachment.
/// </summary>
[JsonProperty(PropertyName = "description")]
public string Description { get; set; }
/// <summary>
/// The reference to the uploaded file to attach to this note.
/// </summary>
[JsonProperty(PropertyName = "attachment_id")]
public int? AttachmentId { get; set; }
/// <summary>
/// The id of the note.
/// </summary>
[JsonProperty(PropertyName = "id")]
public int? Id { get; set; }
/// <summary>
/// The timestamp of the note's creation.
/// </summary>
[JsonProperty(PropertyName = "created")]
public string Created { get; set; }
/// <summary>
/// The timestamp of the note's last update.
/// </summary>
[JsonProperty(PropertyName = "updated")]
public string Updated { get; set; }
/// <summary>
/// The label of the user who created this note.
/// </summary>
[JsonProperty(PropertyName = "label_user_creator")]
public MonetaryAccountReference LabelUserCreator { get; set; }
/// <summary>
/// The attachment attached to the note.
/// </summary>
[JsonProperty(PropertyName = "attachment")]
public List<AttachmentMonetaryAccountPayment> Attachment { get; set; }
/// <summary>
/// </summary>
/// <param name="attachmentId">The reference to the uploaded file to attach to this note.</param>
/// <param name="description">Optional description of the attachment.</param>
public static BunqResponse<int> Create(int mastercardActionId, int? attachmentId, int? monetaryAccountId= null, string description = null, IDictionary<string, string> customHeaders = null)
{
if (customHeaders == null) customHeaders = new Dictionary<string, string>();
var apiClient = new ApiClient(GetApiContext());
var requestMap = new Dictionary<string, object>
{
{FIELD_DESCRIPTION, description},
{FIELD_ATTACHMENT_ID, attachmentId},
};
var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, DetermineUserId(), DetermineMonetaryAccountId(monetaryAccountId), mastercardActionId), requestBytes, customHeaders);
return ProcessForId(responseRaw);
}
/// <summary>
/// </summary>
/// <param name="description">Optional description of the attachment.</param>
public static BunqResponse<int> Update(int mastercardActionId, int noteAttachmentMasterCardActionId, int? monetaryAccountId= null, string description = null, IDictionary<string, string> customHeaders = null)
{
if (customHeaders == null) customHeaders = new Dictionary<string, string>();
var apiClient = new ApiClient(GetApiContext());
var requestMap = new Dictionary<string, object>
{
{FIELD_DESCRIPTION, description},
};
var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
var responseRaw = apiClient.Put(string.Format(ENDPOINT_URL_UPDATE, DetermineUserId(), DetermineMonetaryAccountId(monetaryAccountId), mastercardActionId, noteAttachmentMasterCardActionId), requestBytes, customHeaders);
return ProcessForId(responseRaw);
}
/// <summary>
/// </summary>
public static BunqResponse<object> Delete(int mastercardActionId, int noteAttachmentMasterCardActionId, int? monetaryAccountId= null, IDictionary<string, string> customHeaders = null)
{
if (customHeaders == null) customHeaders = new Dictionary<string, string>();
var apiClient = new ApiClient(GetApiContext());
var responseRaw = apiClient.Delete(string.Format(ENDPOINT_URL_DELETE, DetermineUserId(), DetermineMonetaryAccountId(monetaryAccountId), mastercardActionId, noteAttachmentMasterCardActionId), customHeaders);
return new BunqResponse<object>(null, responseRaw.Headers);
}
/// <summary>
/// Manage the notes for a given user.
/// </summary>
public static BunqResponse<List<NoteAttachmentMasterCardAction>> List(int mastercardActionId, int? monetaryAccountId= null, IDictionary<string, string> urlParams = null, IDictionary<string, string> customHeaders = null)
{
if (urlParams == null) urlParams = new Dictionary<string, string>();
if (customHeaders == null) customHeaders = new Dictionary<string, string>();
var apiClient = new ApiClient(GetApiContext());
var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, DetermineUserId(), DetermineMonetaryAccountId(monetaryAccountId), mastercardActionId), urlParams, customHeaders);
return FromJsonList<NoteAttachmentMasterCardAction>(responseRaw, OBJECT_TYPE_GET);
}
/// <summary>
/// </summary>
public static BunqResponse<NoteAttachmentMasterCardAction> Get(int mastercardActionId, int noteAttachmentMasterCardActionId, int? monetaryAccountId= null, IDictionary<string, string> customHeaders = null)
{
if (customHeaders == null) customHeaders = new Dictionary<string, string>();
var apiClient = new ApiClient(GetApiContext());
var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, DetermineUserId(), DetermineMonetaryAccountId(monetaryAccountId), mastercardActionId, noteAttachmentMasterCardActionId), new Dictionary<string, string>(), customHeaders);
return FromJson<NoteAttachmentMasterCardAction>(responseRaw, OBJECT_TYPE_GET);
}
/// <summary>
/// </summary>
public override bool IsAllFieldNull()
{
if (this.Id != null)
{
return false;
}
if (this.Created != null)
{
return false;
}
if (this.Updated != null)
{
return false;
}
if (this.LabelUserCreator != null)
{
return false;
}
if (this.Description != null)
{
return false;
}
if (this.Attachment != null)
{
return false;
}
return true;
}
/// <summary>
/// </summary>
public static NoteAttachmentMasterCardAction CreateFromJsonString(string json)
{
return BunqModel.CreateFromJsonString<NoteAttachmentMasterCardAction>(json);
}
}
}