forked from MCLDG-zz/non-profit-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ngo-load-workshop.sh
executable file
·313 lines (283 loc) · 13.2 KB
/
ngo-load-workshop.sh
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#!/bin/bash
#
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Script for loading the NGOs and other data used in the workshop, via the REST API
# Set the exports below to point to the REST API hostname/port and run the script
# The export statements below can be used to point to either localhost or to an ELB endpoint,
# depending on where the REST API server is running
set +e
#export ENDPOINT=ngo10-elb-2090058053.us-east-1.elb.amazonaws.com
#export PORT=80
export ENDPOINT=localhost
export PORT=3000
echo '---------------------------------------'
echo connecting to server: $ENDPOINT:$PORT
echo '---------------------------------------'
echo '---------------------------------------'
echo Registering a user
echo '---------------------------------------'
echo 'Register User'
USERID=$(uuidgen)
echo
response=$(curl -s -X POST http://${ENDPOINT}:${PORT}/users -H 'content-type: application/x-www-form-urlencoded' -d "username=${USERID}&orgName=Org1")
echo $response
echo Response should be: {"success":true,"secret":"","message":"$USERID enrolled Successfully"}
echo '---------------------------------------'
echo NGOs
echo '---------------------------------------'
echo 'Creating NGO - 1101'
echo
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/ngos -H 'content-type: application/json' -d '{
"ngoRegistrationNumber": "1101",
"ngoName": "Making the Earth Green",
"ngoDescription": "Our Earth is losing an estimated 18 million acres (7.3 million hectares) of forest every year. The impact of deforestation includes declining biodiversity, ecological imbalances and climate changes around the world. If the current rate of deforestaion continues, it will take less than 100 years to destroy all the rainforests on Earth. Making the Earth Green, a non-profit organization, works with governments, companies and communities to educate and promote responsible forest management practices and protect forest areas. We strongly believe that our children and the future generations deserve a better environment than the current state and it is our responsibility to make that happen. Please donate to make the Earth greener!",
"address": "101 Making the Earth Green",
"contactNumber": "6304972628",
"contactEmail": "[email protected]"
}')
echo "Transaction ID is $TRX_ID"
echo 'Creating NGO - 1102'
echo
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/ngos -H 'content-type: application/json' -d '{
"ngoRegistrationNumber": "1102",
"ngoName": "Books Now Fund",
"ngoDescription": "More than 330 million children, including over 90 percent of primary school age children in low-income countries, and 75 percent of children in lower-middle income countries, are expected not to be able to read by the time they finish primary school. Books Now Fund aims to bring the power of reading to children in these countries, to give them the opportunity to learn, and to encourage them to pursue education. Your donation will help us making the world a better reading place for these children! 1. UNESCO Institute for Statistics. (2017). More Than One-Half of Children and Adolescents Are Not Learning Worldwide. Fact Sheet. Paris: UNESCO. [Accessed 26 January 2018].",
"address": "201 Books Now Fund",
"contactNumber": "6305932628",
"contactEmail": "[email protected]"
}')
echo "Transaction ID is $TRX_ID"
echo 'Creating NGO - 1103'
echo
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/ngos -H 'content-type: application/json' -d '{
"ngoRegistrationNumber": "1103",
"ngoName": "Animal Rescue Troop",
"ngoDescription": "Animal Rescue Troop is a non-profit organization dedicated to animal welfare and shelter. We are volunteer-run and focus on rescuing, rehabilitating and finding forever homes for stray and abandoned animals. There are many ways that you can help: by adopting an animal, providing temporary shelter, becoming a sponsor or donating to our pet shelter. Step up and show that you care!",
"address": "301 Animal Rescue Troop",
"contactNumber": "6309472628",
"contactEmail": "[email protected]"
}')
echo "Transaction ID is $TRX_ID"
echo 'Creating NGO - 1104'
echo
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/ngos -H 'content-type: application/json' -d '{
"ngoRegistrationNumber": "1104",
"ngoName": "Helping Hands",
"ngoDescription": "Helping Hands is a homeless support group. According to a global survey conducted by the United Nations in 2005, an estimated 100 million people were homeless worldwide. Thousands of people around the United States currently face homelessness. During difficult times, local non-profit organizations like ours are vital in providing shelter and support to those in need. We work with local businesses and non-profit partners delivering life-saving services in the communities such as delivering essential backpacks to homeless shelters, sourcing food donations and job placements. Everyone deserved a place to call home, we appreciate your donation to support local communities in overcoming adversity.",
"address": "401 Helping Thousands",
"contactNumber": "6307352628",
"contactEmail": "[email protected]"
}')
echo "Transaction ID is $TRX_ID"
echo 'Creating NGO - 1105'
echo
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/ngos -H 'content-type: application/json' -d '{
"ngoRegistrationNumber": "1105",
"ngoName": "STEM Sprout",
"ngoDescription": "STEM Sprout\u0027s goal is expanding access to Science, Technology, Engineering and Mathematics in schools and increasing participation in these fields of study. Over the next decade, many of the 30+ fastest growing jobs will require STEM skills. We work with schools in our communities to organize activities and develop curricula. We want to ensure that understanding techology become a basic skill for our next generation. Giving children the resources and empowering them to understand even the basics of sciences would open up so many options and opportunities for them down the road. Come and help to open doors to STEM for our children!",
"address": "1501 STEM",
"contactNumber": "8574639353",
"contactEmail": "[email protected]"
}')
echo "Transaction ID is $TRX_ID"
echo 'Checking that the data has been loaded'
echo 'Query all NGOs'
echo
curl -s -X GET http://${ENDPOINT}:${PORT}/ngos -H 'content-type: application/json'
echo
echo 'Query specific NGOs - looking for NGO 1103'
echo
curl -s -X GET http://${ENDPOINT}:${PORT}/ngos/1103 -H 'content-type: application/json'
echo '---------------------------------------'
echo Rating
echo '---------------------------------------'
echo 'Create Rating'
echo
RATING1=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/ratings -H 'content-type: application/json' -d '{
"donorUserName": "'"${DONOR1}"'",
"ngoRegistrationNumber": "1103",
"rating": 4
}')
echo "Transaction ID is $TRX_ID"
echo
RATING2=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/ratings -H 'content-type: application/json' -d '{
"donorUserName": "'"${DONOR2}"'",
"ngoRegistrationNumber": "1101",
"rating": 5
}')
echo "Transaction ID is $TRX_ID"
echo
RATING3=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/ratings -H 'content-type: application/json' -d '{
"donorUserName": "'"${DONOR2}"'",
"ngoRegistrationNumber": "1105",
"rating": 3
}')
echo "Transaction ID is $TRX_ID"
echo '---------------------------------------'
echo Donors
echo '---------------------------------------'
echo 'Create Donor'
echo
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donors -H 'content-type: application/json' -d '{
"donorUserName": "jane",
"email": "[email protected]",
"registeredDate": "2018-10-21T09:52:20.182Z"
}')
echo "Transaction ID is $TRX_ID"
echo
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donors -H 'content-type: application/json' -d '{
"donorUserName": "louisa",
"email": "[email protected]",
"registeredDate": "2018-11-18T05:32:20.182Z"
}')
echo "Transaction ID is $TRX_ID"
echo 'Query all donors'
echo
curl -s -X GET http://${ENDPOINT}:${PORT}/donors -H 'content-type: application/json'
echo '---------------------------------------'
echo Donation
echo '---------------------------------------'
echo
echo 'Create Donation'
echo
DONATION1=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION1}"'",
"donationAmount": 100,
"donationDate": "2018-09-20T12:41:59.582Z",
"donorUserName": "edge",
"ngoRegistrationNumber": "1102"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION2=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION2}"'",
"donationAmount": 255,
"donationDate": "2018-09-18T07:41:59.582Z",
"donorUserName": "jane",
"ngoRegistrationNumber": "1105"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION3=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION3}"'",
"donationAmount": 900,
"donationDate": "2018-09-09T06:32:59.582Z",
"donorUserName": "louisa",
"ngoRegistrationNumber": "1103"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION4=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION4}"'",
"donationAmount": 430,
"donationDate": "2018-08-09T09:32:59.582Z",
"donorUserName": "braendle",
"ngoRegistrationNumber": "1103"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION5=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION5}"'",
"donationAmount": 200,
"donationDate": "2018-09-18T07:41:59.582Z",
"donorUserName": "edge",
"ngoRegistrationNumber": "1103"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION6=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION6}"'",
"donationAmount": 520,
"donationDate": "2018-09-20T12:41:59.582Z",
"donorUserName": "edge",
"ngoRegistrationNumber": "1101"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION7=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION7}"'",
"donationAmount": 760,
"donationDate": "2018-09-18T07:41:59.582Z",
"donorUserName": "jane",
"ngoRegistrationNumber": "1105"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION8=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION8}"'",
"donationAmount": 25,
"donationDate": "2018-09-09T06:32:59.582Z",
"donorUserName": "louisa",
"ngoRegistrationNumber": "1101"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION9=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION9}"'",
"donationAmount": 44,
"donationDate": "2018-08-09T09:32:59.582Z",
"donorUserName": "braendle",
"ngoRegistrationNumber": "1103"
}')
echo "Transaction ID is $TRX_ID"
echo
DONATION10=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json' -d '{
"donationId": "'"${DONATION10}"'",
"donationAmount": 120,
"donationDate": "2018-09-18T07:41:59.582Z",
"donorUserName": "edge",
"ngoRegistrationNumber": "1104"
}')
echo "Transaction ID is $TRX_ID"
echo 'Query all Donations'
echo
curl -s -X GET http://${ENDPOINT}:${PORT}/donations -H 'content-type: application/json'
echo '---------------------------------------'
echo Spend
echo '---------------------------------------'
echo 'Create Spend'
echo
SPENDID=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/spend -H 'content-type: application/json' -d '{
"ngoRegistrationNumber": "1103",
"spendId": "'"${SPENDID}"'",
"spendDescription": "Fees for hiring transport for animal delivery",
"spendDate": "2018-11-19T12:20:59.582Z",
"spendAmount": 125
}')
echo "Transaction ID is $TRX_ID"
echo
SPENDID=$(uuidgen)
TRX_ID=$(curl -s -X POST http://${ENDPOINT}:${PORT}/spend -H 'content-type: application/json' -d '{
"ngoRegistrationNumber": "1105",
"spendId": "'"${SPENDID}"'",
"spendDescription": "Purchase test tubes",
"spendDate": "2018-09-10T22:41:59.582Z",
"spendAmount": 99
}')
echo "Transaction ID is $TRX_ID"