Skip to content

Commit d4fc0eb

Browse files
author
Kevin Hellemun
committed
Initial commit.
1 parent e27c8d0 commit d4fc0eb

19 files changed

+1667
-0
lines changed

.gitignore

+297
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
# Created by https://www.gitignore.io/api/csharp
2+
3+
### Csharp ###
4+
## Ignore Visual Studio temporary files, build results, and
5+
## files generated by popular Visual Studio add-ons.
6+
##
7+
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
8+
9+
# User-specific files
10+
*.suo
11+
*.user
12+
*.userosscache
13+
*.sln.docstates
14+
15+
# User-specific files (MonoDevelop/Xamarin Studio)
16+
*.userprefs
17+
18+
# Build results
19+
[Dd]ebug/
20+
[Dd]ebugPublic/
21+
[Rr]elease/
22+
[Rr]eleases/
23+
x64/
24+
x86/
25+
bld/
26+
[Bb]in/
27+
[Oo]bj/
28+
[Ll]og/
29+
30+
# Visual Studio 2015 cache/options directory
31+
.vs/
32+
# Uncomment if you have tasks that create the project's static files in wwwroot
33+
#wwwroot/
34+
35+
# MSTest test Results
36+
[Tt]est[Rr]esult*/
37+
[Bb]uild[Ll]og.*
38+
39+
# NUNIT
40+
*.VisualState.xml
41+
TestResult.xml
42+
43+
# Build Results of an ATL Project
44+
[Dd]ebugPS/
45+
[Rr]eleasePS/
46+
dlldata.c
47+
48+
# .NET Core
49+
project.lock.json
50+
project.fragment.lock.json
51+
artifacts/
52+
**/Properties/launchSettings.json
53+
54+
*_i.c
55+
*_p.c
56+
*_i.h
57+
*.ilk
58+
*.meta
59+
*.obj
60+
*.pch
61+
*.pdb
62+
*.pgc
63+
*.pgd
64+
*.rsp
65+
*.sbr
66+
*.tlb
67+
*.tli
68+
*.tlh
69+
*.tmp
70+
*.tmp_proj
71+
*.log
72+
*.vspscc
73+
*.vssscc
74+
.builds
75+
*.pidb
76+
*.svclog
77+
*.scc
78+
79+
# Chutzpah Test files
80+
_Chutzpah*
81+
82+
# Visual C++ cache files
83+
ipch/
84+
*.aps
85+
*.ncb
86+
*.opendb
87+
*.opensdf
88+
*.sdf
89+
*.cachefile
90+
*.VC.db
91+
*.VC.VC.opendb
92+
93+
# Visual Studio profiler
94+
*.psess
95+
*.vsp
96+
*.vspx
97+
*.sap
98+
99+
# TFS 2012 Local Workspace
100+
$tf/
101+
102+
# Guidance Automation Toolkit
103+
*.gpState
104+
105+
# ReSharper is a .NET coding add-in
106+
_ReSharper*/
107+
*.[Rr]e[Ss]harper
108+
*.DotSettings.user
109+
110+
# JustCode is a .NET coding add-in
111+
.JustCode
112+
113+
# TeamCity is a build add-in
114+
_TeamCity*
115+
116+
# DotCover is a Code Coverage Tool
117+
*.dotCover
118+
119+
# Visual Studio code coverage results
120+
*.coverage
121+
*.coveragexml
122+
123+
# NCrunch
124+
_NCrunch_*
125+
.*crunch*.local.xml
126+
nCrunchTemp_*
127+
128+
# MightyMoose
129+
*.mm.*
130+
AutoTest.Net/
131+
132+
# Web workbench (sass)
133+
.sass-cache/
134+
135+
# Installshield output folder
136+
[Ee]xpress/
137+
138+
# DocProject is a documentation generator add-in
139+
DocProject/buildhelp/
140+
DocProject/Help/*.HxT
141+
DocProject/Help/*.HxC
142+
DocProject/Help/*.hhc
143+
DocProject/Help/*.hhk
144+
DocProject/Help/*.hhp
145+
DocProject/Help/Html2
146+
DocProject/Help/html
147+
148+
# Click-Once directory
149+
publish/
150+
151+
# Publish Web Output
152+
*.[Pp]ublish.xml
153+
*.azurePubxml
154+
# TODO: Uncomment the next line to ignore your web deploy settings.
155+
# By default, sensitive information, such as encrypted password
156+
# should be stored in the .pubxml.user file.
157+
#*.pubxml
158+
*.pubxml.user
159+
*.publishproj
160+
161+
# Microsoft Azure Web App publish settings. Comment the next line if you want to
162+
# checkin your Azure Web App publish settings, but sensitive information contained
163+
# in these scripts will be unencrypted
164+
PublishScripts/
165+
166+
# NuGet Packages
167+
*.nupkg
168+
# The packages folder can be ignored because of Package Restore
169+
**/packages/*
170+
# except build/, which is used as an MSBuild target.
171+
!**/packages/build/
172+
# Uncomment if necessary however generally it will be regenerated when needed
173+
#!**/packages/repositories.config
174+
# NuGet v3's project.json files produces more ignorable files
175+
*.nuget.props
176+
*.nuget.targets
177+
178+
# Microsoft Azure Build Output
179+
csx/
180+
*.build.csdef
181+
182+
# Microsoft Azure Emulator
183+
ecf/
184+
rcf/
185+
186+
# Windows Store app package directories and files
187+
AppPackages/
188+
BundleArtifacts/
189+
Package.StoreAssociation.xml
190+
_pkginfo.txt
191+
192+
# Visual Studio cache files
193+
# files ending in .cache can be ignored
194+
*.[Cc]ache
195+
# but keep track of directories ending in .cache
196+
!*.[Cc]ache/
197+
198+
# Others
199+
ClientBin/
200+
~$*
201+
*~
202+
*.dbmdl
203+
*.dbproj.schemaview
204+
*.jfm
205+
*.pfx
206+
*.publishsettings
207+
orleans.codegen.cs
208+
209+
# Since there are multiple workflows, uncomment next line to ignore bower_components
210+
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
211+
#bower_components/
212+
213+
# RIA/Silverlight projects
214+
Generated_Code/
215+
216+
# Backup & report files from converting an old project file
217+
# to a newer Visual Studio version. Backup files are not needed,
218+
# because we have git ;-)
219+
_UpgradeReport_Files/
220+
Backup*/
221+
UpgradeLog*.XML
222+
UpgradeLog*.htm
223+
224+
# SQL Server files
225+
*.mdf
226+
*.ldf
227+
*.ndf
228+
229+
# Business Intelligence projects
230+
*.rdl.data
231+
*.bim.layout
232+
*.bim_*.settings
233+
234+
# Microsoft Fakes
235+
FakesAssemblies/
236+
237+
# GhostDoc plugin setting file
238+
*.GhostDoc.xml
239+
240+
# Node.js Tools for Visual Studio
241+
.ntvs_analysis.dat
242+
node_modules/
243+
244+
# Typescript v1 declaration files
245+
typings/
246+
247+
# Visual Studio 6 build log
248+
*.plg
249+
250+
# Visual Studio 6 workspace options file
251+
*.opt
252+
253+
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
254+
*.vbw
255+
256+
# Visual Studio LightSwitch build output
257+
**/*.HTMLClient/GeneratedArtifacts
258+
**/*.DesktopClient/GeneratedArtifacts
259+
**/*.DesktopClient/ModelManifest.xml
260+
**/*.Server/GeneratedArtifacts
261+
**/*.Server/ModelManifest.xml
262+
_Pvt_Extensions
263+
264+
# Paket dependency manager
265+
.paket/paket.exe
266+
paket-files/
267+
268+
# FAKE - F# Make
269+
.fake/
270+
271+
# JetBrains Rider
272+
.idea/
273+
*.sln.iml
274+
275+
# CodeRush
276+
.cr/
277+
278+
# Python Tools for Visual Studio (PTVS)
279+
__pycache__/
280+
*.pyc
281+
282+
# Cake - Uncomment if you are using it
283+
# tools/**
284+
# !tools/packages.config
285+
286+
# Telerik's JustMock configuration file
287+
*.jmconfig
288+
289+
# BizTalk build output
290+
*.btp.cs
291+
*.btm.cs
292+
*.odx.cs
293+
*.xsd.cs
294+
295+
296+
# End of https://www.gitignore.io/api/csharp
297+

TinkerSrc/AddCallbackUrl.cs

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Bunq.Sdk.Context;
4+
using Bunq.Sdk.Exception;
5+
using Bunq.Sdk.Model.Generated.Endpoint;
6+
using Bunq.Sdk.Model.Generated.Object;
7+
using Tinker.Utils;
8+
using TinkerSrc.Lib;
9+
10+
namespace TinkerSrc
11+
{
12+
public class AddCallbackUrl : ITinker
13+
{
14+
public void Run(string[] args)
15+
{
16+
var environmentType = ShareLib.DetermineEnvironmentType(args);
17+
18+
ShareLib.PrintHeader();
19+
20+
var bunq = new BunqLib(environmentType);
21+
22+
var callbackUrl = ShareLib.GetCallbackUrlFromArgsOrStdIn(args);
23+
24+
Console.Out.WriteLine();
25+
Console.Out.WriteLine($" | Adding Callback URL: {callbackUrl}");
26+
Console.Out.WriteLine();
27+
Console.Out.WriteLine(" ...");
28+
Console.Out.WriteLine();
29+
30+
if (BunqContext.UserContext.isOnlyUserCompanySet())
31+
{
32+
UserCompany.Update(
33+
notificationFilters: UpdateAllNotificationFilter(
34+
BunqContext.UserContext.UserCompany.NotificationFilters,
35+
callbackUrl
36+
)
37+
);
38+
}
39+
else if (BunqContext.UserContext.IsOnlyUserPersonSet())
40+
{
41+
UserPerson.Update(
42+
notificationFilters: UpdateAllNotificationFilter(
43+
BunqContext.UserContext.UserPerson.NotificationFilters,
44+
callbackUrl
45+
)
46+
);
47+
}
48+
else
49+
{
50+
throw new BunqException("Unexpected user type found.");
51+
}
52+
53+
Console.Out.WriteLine();
54+
Console.Out.WriteLine(" | Callback URL added");
55+
Console.Out.WriteLine();
56+
Console.Out.WriteLine(" | Check your changed overview");
57+
Console.Out.WriteLine();
58+
Console.Out.WriteLine();
59+
60+
bunq.UpdateContext();
61+
}
62+
63+
private List<NotificationFilter> UpdateAllNotificationFilter(
64+
List<NotificationFilter> allNotificationFilter,
65+
string callbackUrl
66+
)
67+
{
68+
List<NotificationFilter> allNotificationFilterUpdated = new List<NotificationFilter>();
69+
70+
foreach (var notificationFilter in allNotificationFilter)
71+
{
72+
if (callbackUrl.Equals(notificationFilter.NotificationTarget) == false)
73+
{
74+
allNotificationFilterUpdated.Add(notificationFilter);
75+
}
76+
}
77+
78+
allNotificationFilterUpdated.Add(new NotificationFilter("URL", callbackUrl, "MUTATION"));
79+
80+
return allNotificationFilterUpdated;
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)