Please suggest about how to create relation in Core Data in the following situation: I created a user object which contained 2 relations pointing to the same object (address) but relation names are homeAddress and workAddress. But on Xcode5 it gives some warning that the inverse relation is not reciprocal.
JSON:
{
"user": {
"user_id": "123123",
"email": "user#email.com",
"first_name": "Jean Luc",
"last_name": "Picard",
"home_address": {
"street": "DowningStreet",
"number": "11",
"city": "London",
"state": "GreaterLondon",
"country": "UnitedKingdom",
"zip": "SW1A2QAB",
"name": "Homesweethome",
"created_at": "1365526421456",
"location": {
"latitude": 3.1,
"longitude": 3.2
}
},
"work_address": {
"street": "AmphitheatreParkway",
"number": "1600",
"city": "MountainView",
"state": "California",
"country": "UnitedStates",
"zip": "94043",
"name": "WorkHarder",
"created_at": "1365526642123",
"location": {
"latitude": 3.1,
"longitude": 3.2
}
}
}
}
I want to avoid creating 2 separate address objects.
Related
[
{
"id": 1,
"gender": "male",
"name": "Harry",
"contact": "01765489231",
"address": "park view road, Dhaka",
"photoUrl": "https://images.unsplash.com/flagged/photo-1570612861542-284f4c12e75f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8cGVyc29ufGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=500&q=60"
},
{
"id": 2,
"gender": "male",
"name": "Xavier",
"contact": "01648935261",
"address": "Ring house, Bogra",
"photoUrl": "https://images.unsplash.com/photo-1547425260-76bcadfb4f2c?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NXx8cGVyc29ufGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=500&q=60"
},
{
"id": 3,
"gender": "female",
"name": "Anyy",
"contact": "01554783921",
"address": "321 street, Comilla",
"photoUrl": "https://images.unsplash.com/photo-1499952127939-9bbf5af6c51c?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MTJ8fHBlcnNvbnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=500&q=60"
},
{
"id": 4,
"gender": "female",
"name": "Ember",
"contact": "01812398654",
"address": "Golden street, Rajshahi",
"photoUrl": "https://images.unsplash.com/photo-1593104547489-5cfb3839a3b5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MzB8fHBlcnNvbnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=500&q=60"
},
{
"id": 5,
"gender": "male",
"name": "Gerrad",
"contact": "01946378254",
"address": "Ali complex, Khulna",
"photoUrl": "https://images.unsplash.com/photo-1568602471122-7832951cc4c5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NDV8fHBlcnNvbnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=500&q=60"
}
]
After hitting '/user/bulk-update' route I have to do the following:
Take an array of user ids and assign it to the body.
Update multiple users' information in this .json file
Please don't just ask for code next time.
const data = JSON.parse(fs.readFileSync('myjson.json'));
const {ids} = req.body;
data.forEach(entry => {
// Do your things here
})
Assuming you have a server already set up.
How do i a write a query that will copy the phoneNumber from data.accounts.contact.phone.phoneNumber to data.phoneNumber in jsonb postgres.
I tried this command
UPDATE customer."user" SET domain = jsonb_set(domain,'{phoneNumber}', text('domain' ->'accounts'-> 0 -> 'contacts' -> 'phone' -> 'phoneNumber'))
but got this error
Error: HINT: Could not choose a best candidate operator. You might need to add explicit type casts.
SQL state: 42725
Character: 1913
{
"id": "87b31b1f-5dae-4506-8099-9812fa1633eb",
"gender": "F",
"status": "VERIFIED",
"lastName": "Lawal",
"password": "T3m1t0p3",
"username": "aminat2#gmail.com",
"firstName": "Aminat",
"phoneNumber": "",
"accounts": [
{
"status": "IN_REVIEW",
"contact": {
"phone": { "phoneNumber": "7809284029", "diallingCode": "+44" },
"address": { "city": "London", "address": "42 Sark Walk", "country": "United Kingdom", "postcode": "E163PS" },
"emailAddress": "aminat2#gmail.com"
},
"location": {
"id": "4a110b1f-9319-4282-b645-81ea71b53e04",
"status": "ACTIVE",
"currency": {
"id": "1",
"to": false,
"date": "2021-09-19T16:45:33",
"from": true,
"buyFxRate": "1",
"sellFxRate": "1",
"
},
"diallingCode": "+44",
"locationLabel": "United Kingdom",
"
"modifiedDateTime": "2021-09-19T16:45:33",
},
}
],
}
The response i am getting is below Which i need to convert the input JSON Format to other JSON structure and send the response back. I am struck how to get the data from the JSOn and construct the new JSON format
{
"totalSize": 1,
"done": true,
"records": [{
"attributes": {
"type": "test123",
"url": "/services/data/testapp"
},
"Id": "8373837",
"Name": "6294",
"Application": "9932932932",
"contact": {
"attributes": {
"type": "testcon",
"url": "/services/data/testappsss"
},
"Name": "testName",
"FirstName": "test",
"LastName": "name",
"MailingStreet": null,
"MailingCity": null,
"unemail": "testname#test,.co",
"MailingState": null,
"MailingCountry": null,
"MailingPostalCode": null,
"stuId": "328237832"
},
"currentusbss": "83277832873278",
"currentsu": {
"attributes": {
"type": "testsub",
"url": "/services/data/v44.0jsjsj"
},
"price": 2,
"Name": "SUB-20426"
},
"bal": 234,
"startdate": "2020-02-03",
"enddate": "2020-05-03"
}]
}
I need to convert above JSON format to below JSON format and send it using set-body method in out-bond policies
{
"info": {
"studentName": "testName",
"studentFirstName": "test",
"studentMiddleName": "",
"studentLastName": "Name",
"studentEmail": "testname#test,.co",
"role": "STUDENT",
"billingCountryCode": "US",
"systemId": "XX",
"stuId": "328237832"
},
"address": {
"address1": "1234 Grove St",
"address2": "",
"city": "Tempe",
"countryCode": "US",
"countryDescription": "UNITED STATES",
"stateCode": "AZ",
"stateDescription": "Arizona",
"postalCode": "45235",
"foreignState": "Arizona",
"region": "Domestic",
"phoneNumber": ""
},
"account": {
"institutionId": "1",
"paymentPlan": "N",
"currencyDesc": "United States Dollars",
"currencyType": "USD",
"bal": 234,
"daysLate":"18",
"opportunityId": "9932932932",
"studentParameterName": null,
"studentParameterValue": null
},
"studentTerms": [
{
"startdate": "2020-02-03",
"enddate": "2020-05-03",
"Name": "SUB-20426",
"description": "XQYember 03, 2020 "
}
]
}
You can use Liquid Template for this case:
Using Liquid Templates in Azure API Management
Using Liquid templates with set body
Or you create a new body in the outbound-section with a new JObject
Okay I am setting up Partial Payments via the Authorize.net API in order to enable multiple cards to be used to cover a single balance/charge.
I'm assuming thier Partial Auth feature covers my use case, but in testing, there is an issue I can show you using the API live console here: https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-credit-card
Go to the link above and authorize partial payments with the request I edited below and you will notice when you press submit you get a splitTenderId:
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "5KP3u95bQpv",
"transactionKey": "346HZ32z3fP4hTG2"
},
"refId": "123456",
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": "462.25",
"payment": {
"creditCard": {
"cardNumber": "5424000000000015",
"expirationDate": "2020-12",
"cardCode": "999"
}
},
"lineItems": {
"lineItem": {
"itemId": "1",
"name": "vase",
"description": "Cannes logo",
"quantity": "18",
"unitPrice": "45.00"
}
},
"tax": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"duty": {
"amount": "8.55",
"name": "duty name",
"description": "duty description"
},
"shipping": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"poNumber": "456654",
"customer": {
"id": "99999456654"
},
"billTo": {
"firstName": "Ellen",
"lastName": "Johnson",
"company": "Souveniropolis",
"address": "14 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"shipTo": {
"firstName": "China",
"lastName": "Bayles",
"company": "Thyme for Tea",
"address": "12 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"customerIP": "192.168.1.1",
"transactionSettings": {
"setting": [
{
"settingName": "emailCustomer",
"settingValue": "true"
}, {
"settingName": "allowPartialAuth",
"settingValue": "true"
},
]
},
"userFields": {
"userField": [
{
"name": "MerchantDefinedFieldName1",
"value": "MerchantDefinedFieldValue1"
},
{
"name": "favorite_color",
"value": "blue"
}
]
}
}
}
}
This is only successful because the amount is 462.25 as the docs say to use for testing, if I use any other (real) amount the splitTenderId is not there.
Here is a new example request, you can post this again on the link above:
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "5KP3u95bQpv",
"transactionKey": "346HZ32z3fP4hTG2"
},
"refId": "123456",
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": "462",
"payment": {
"creditCard": {
"cardNumber": "5424000000000015",
"expirationDate": "2020-12",
"cardCode": "999"
}
},
"lineItems": {
"lineItem": {
"itemId": "1",
"name": "vase",
"description": "Cannes logo",
"quantity": "18",
"unitPrice": "45.00"
}
},
"tax": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"duty": {
"amount": "8.55",
"name": "duty name",
"description": "duty description"
},
"shipping": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"poNumber": "456654",
"customer": {
"id": "99999456654"
},
"billTo": {
"firstName": "Ellen",
"lastName": "Johnson",
"company": "Souveniropolis",
"address": "14 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"shipTo": {
"firstName": "China",
"lastName": "Bayles",
"company": "Thyme for Tea",
"address": "12 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"customerIP": "192.168.1.1",
"transactionSettings": {
"setting": [
{
"settingName": "emailCustomer",
"settingValue": "true"
}, {
"settingName": "allowPartialAuth",
"settingValue": "true"
},
]
},
"userFields": {
"userField": [
{
"name": "MerchantDefinedFieldName1",
"value": "MerchantDefinedFieldValue1"
},
{
"name": "favorite_color",
"value": "blue"
}
]
}
}
}
}
And with the 462 amount entered this is no longer a partial auth payment and I no longer get a splitTenderId.
Can someone please help me figure out what is going on?
I have a huge dataset that increases by hundreds/thousands items for sale every few minutes. I will be parsing this data as it comes in and I'm looking for suggestions on how to efficiently match new incoming items with users who want the item.
Examples of how other have done this would mean the world to me. Even just clarification on what to search for online would be helpful. I'm having difficulty asking the right questions to search engines so I can learn how to solve this (usually I'm very good at this sort of thing).
Thank you fellow geniuses!
p.s. Hoping so solve this problem with nodejs
Inventory Dataset Example:
{
"anchor": 982179125,
"next_page": 1,
"next_tier": 0,
"num_matches": 47037,
"postings": [
{
"category": "SBIK",
"category_group": "SSSS",
"external_id": "4488716340",
"heading": "60cm Aluminum/Carbon Road Bike, Ultegra/105 equipped, 20-Spd",
"location": {
"accuracy": 8,
"city": "USA-SFO-SNF",
"country": "USA",
"county": "USA-CA-SAF",
"geolocation_status": 3,
"lat": "37.801041",
"locality": "USA-SFO-MRS",
"long": "-122.434151",
"metro": "USA-SFO",
"region": "USA-SFO-SAF",
"state": "USA-CA",
"zipcode": "USA-94123"
},
"price": 800.0
},
{
"category": "SBOT",
"category_group": "SSSS",
"external_id": "4488164318",
"heading": "Burley Bee Boat Trailer",
"location": {
"accuracy": 8,
"city": "USA-SFO-SNF",
"country": "USA",
"county": "USA-CA-SAF",
"geolocation_status": 3,
"lat": "37.7999",
"locality": "USA-SFO-MRS",
"long": "-122.4342",
"metro": "USA-SFO",
"region": "USA-SFO-SAF",
"state": "USA-CA",
"zipcode": "USA-94123"
},
"price": 150.0
},
{
"category": "SAUT",
"category_group": "SSSS",
"external_id": "4459983854",
"heading": "Car frame extra light castom made",
"location": {
"accuracy": 8,
"city": "USA-SFO-SNF",
"country": "USA",
"county": "USA-CA-SAF",
"geolocation_status": 3,
"lat": "37.7999",
"locality": "USA-SFO-MRS",
"long": "-122.4342",
"metro": "USA-SFO",
"region": "USA-SFO-SAF",
"state": "USA-CA",
"zipcode": "USA-94123"
},
"price": 300.0
},
"success": true,
"time_fetch": 9.4971656799316406,
"time_search": 42.315006256103516,
"time_taken": 183.84885787963867
}
My users are looking for:
{name:"tom",wants:"new car"}
{name:"john",wants:"Road Bike",price:[low:100,high:1000]}
{name:"becky",wants:"dolls"}
{name:"sam",wants:"Drobo",price:[low:0,high:500]}]
...
...
...