Querying data on S3 Object - amazon-web-services

Trying to query data on json file using S3-Select
{
"groups_id":
{
"307225":
{
"created_at": "2015-02-10T17:24:15-08:00",
"updated_at": "2017-09-06T17:25:22-07:00",
"name": "Company 1",
"company": true,
"contact_name": "User 1",
"email": "",
"phone_number": "",
"address": "",
"website": "",
"notes": "Testing",
"id": "307225"
},
"1058565":
{
"created_at": "2017-04-02T23:44:10-07:00",
"updated_at": "2017-07-18T17:39:21-07:00",
"name": "Company 3",
"company": true,
"contact_name": "User 1",
"email": "",
"phone_number": "",
"address": "",
"website": "",
"notes": null,
"id": "1058565"
}
}
}
Can someone help to get the desired output using s3 select, based on the condition as WHERE contact_name='User 1'.
{"id": "307225", "name": "Company 1"},
{"id": "1058565","name": "Company 3"}
below are the queries we had tried,
Select s.groups_id['307225'].id from s3object s
Select s.groups_id['1058565'].id from s3object s
in the above queries, we had hardcoded the group_id and we are able to fetch below
{
"id": "1058565"
}
but in our case groupid is dynamic so i am not understanding. how to handle that?

Related

How to get the last createdAt item with TypeORM

Hi friends I need help with this query that I want to make to return only the last 'Case' by 'User'.
On my PostMan request I have my service that returns all the cases that the user have made.
users.services.ts
async findCasesbyUserId(id: number) {
return await this.usersRepository.findOne(id, { relations: ['cases']})
}
users.controller.ts
#Get('/findCase/:id')
async findCasesByUserId(#Param('id', ParseIntPipe) id: number,) {
return this.usersService.findCasesbyUserId(id)
}
When I made my GET request to 'http://localhost:3000/users/findCase/3'. This is the result that I get.
The user with id=3 have the cases with the id=1, id=2, id=3
So I want only to return only the case with the id=3 because is the last created case. I need a way to get the last case by the field createdAt or another way could be great for me.
Im using NestJs with TypeORM for thew querys to my PostgreSQL DB.
{
"id": 3,
"createdAt": "1617983079621",
"updatedAt": "1617983079621",
"name": "John",
"lastname": "Doe",
"email": "jdoe#email.com",
"username": "JohnDoe",
"password": "**************",
"role": "Admin",
"isActive": true,
"document": "12345",
"address": "Test",
"phone": "12345",
"cases": [
{
"id": 1,
"createdAt": "1618504530817",
"updatedAt": "1618504530817",
"message": "Test Case 1",
},
{
"id": 2,
"createdAt": "1618504530817",
"updatedAt": "1618504530817",
"message": "Test Case 1",
}, {
"id": 3,
"createdAt": "1618546146772",
"updatedAt": "1618546146772",
"message": "Test Case 1",
},
]
}

Can I get all active ARB subscription in a single API call

Current I'm exporting all ARB data by calling API to get all active ARB ids then go through each ARB id to get info stored in each ID. But this process is too long and it makes lots of requests. Is there any way so that I can get all active ARB ids data in one request like that of any database?
https://developer.authorize.net/api/reference/index.html#recurring-billing-get-a-list-of-subscriptions
This function gives only small amount data while I need complete data stored in a profile like this one: https://developer.authorize.net/api/reference/index.html#recurring-billing-get-subscription
But this function only works for single ID.
New Answer
No. The ARBGetSubscriptionListRequest only returns a limited amount of information. If you want detailed information you would need to call ARBGetSubscriptionListRequest and then loop through the results and make an API call for each subscription to get the more granular data.
Due to the potentially large amount of results, you probably should store the results in a database and then have a bunch of scheduled scripts make the subsequent API calls.
Old Answer
Yes. You can call ARBGetSubscriptionListRequest.
Request:
{
"ARBGetSubscriptionListRequest": {
"merchantAuthentication": {
"name": "5KP3u95bQpv",
"transactionKey": "346HZ32z3fP4hTG2"
},
"refId": "123456",
"searchType": "subscriptionActive",
"sorting": {
"orderBy": "id",
"orderDescending": "false"
},
"paging": {
"limit": "1000",
"offset": "1"
}
}
}
Response:
{
"totalNumInResultSet": 1273,
"totalNumInResultSetSpecified": true,
"subscriptionDetails": [
{
"id": 100188,
"name": "subscription",
"status": "canceled",
"createTimeStampUTC": "2004-04-28T23:59:47.33",
"firstName": "Joe",
"lastName": "Tester",
"totalOccurrences": 12,
"pastOccurrences": 6,
"paymentMethod": "creditCard",
"accountNumber": "XXXX5454",
"invoice": "42820041325496571",
"amount": 10,
"currencyCode": "USD"
},
{
"id": 100222,
"name": "",
"status": "canceled",
"createTimeStampUTC": "2004-10-22T21:00:15.503",
"firstName": "asdf",
"lastName": "asdf",
"totalOccurrences": 12,
"pastOccurrences": 0,
"paymentMethod": "creditCard",
"accountNumber": "XXXX1111",
"invoice": "",
"amount": 1,
"currencyCode": "USD"
},
{
"id": 100223,
"name": "",
"status": "canceled",
"createTimeStampUTC": "2004-10-22T21:01:27.69",
"firstName": "asdf",
"lastName": "asdf",
"totalOccurrences": 12,
"pastOccurrences": 1,
"paymentMethod": "eCheck",
"accountNumber": "XXXX3888",
"invoice": "",
"amount": 10,
"currencyCode": "USD"
}
],
"refId": "123456",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}

How to fetch API data as this. props?

I am trying to fetch data from API in react component as
{this.props.buyer && this.props.buyer[0].phone_number[0].number} - it's throwing error
Cannot read property 'number' of undefined
{this.props.buyer && this.props.buyer[0].name} - it's working fine
This is the API data
Orders: {
buyer:
},
}
[
{
"id": 2,
"name": "Qi Xiang",
"type": "Consignee",
"address": {
"id": 2,
"type": "shipping",
"street": "China China",
"city": "Beijing",
"postal_code": "34343",
"province": "23232",
"country": "CN"
},
"email": null,
"phone_number": {
"number": "323232",
"type": "Phone"
},
"id_image_url": "/api/files/24e49645-df42-4984-a
}
]
},
}
Your phonenumber is not array. You must use this:
this.props.buyer[0].phone_number.number

How to solve the error of The element 'createCustomerProfileRequest' in namespace while adding the customer mutiple payment

I want to add the multiple payment profiles of a single customer in authorize.net. After a long searching I reached a post posted on the community of the authorize.net see link. In this link there a xml formated data in the accepted solution I convert it and send it through the postman then I'm facing the error of
"The element 'createCustomerProfileRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element '_xmlns' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."
The json I'm sending is :-
{
"createCustomerProfileRequest": {
"merchantAuthentication": {
"name": "name",
"transactionKey": "transactionKey"
},
"refId": "1361101257555",
"profile": {
"merchantCustomerId": "2CLINC056",
"description": "hiiiiii.",
"email": "",
"paymentProfiles": [
{
"customerType": "individual",
"billTo": {
"firstName": "Joe",
"lastName": "Test",
"company": "CompanyA",
"address": "hello",
"city": "Bangalore",
"state": "Delhi",
"zip": "560078",
"country": "IN",
"phoneNumber": "415-555-1212",
"faxNumber": "415-555-1313"
},
"payment": {
"creditCard": {
"cardNumber": "370000000000002",
"expirationDate": "2029-12"
}
}
},
{
"customerType": "individual",
"billTo": {
"firstName": "Joe",
"lastName": "Test",
"company": "CompanyA",
"address": "vel",
"city": "Chennai",
"state": "AK",
"zip": "560089",
"country": "US",
"phoneNumber": "415-555-1212",
"faxNumber": "415-555-1313"
},
"payment": {
"creditCard": {
"cardNumber": "38000000000006",
"expirationDate": "2029-12"
}
}
}
]
},
"validationMode": "testMode",
"_xmlns": "AnetApi/xml/v1/schema/AnetApiSchema.xsd"
}
}
Developer link
I think your issue is not with the payment profiles but with the JSON itself. You have an invalid element in there and I think it is this line:
"_xmlns": "AnetApi/xml/v1/schema/AnetApiSchema.xsd"
Otherwise your request looks fine as I was able to create multiple payment profiles using similar JSON. The only difference between the two was my JSON didn't have that line.
Request JSON:
{
"createCustomerProfileRequest": {
"merchantAuthentication": {
"name": "xxxxxxxx",
"transactionKey": "xxxxxxxxxxxxxxxx"
},
"profile": {
"merchantCustomerId": "52353345",
"email": "user#example.com",
"paymentProfiles": [
{
"customerType": "individual",
"billTo": {
"firstName": "John",
"lastName": "Smith",
"address": "12345 Main Street",
"city": "Townsville",
"state": "NJ",
"zip": "12345",
"phoneNumber": "800-555-1234"
},
"payment": {
"creditCard": {
"cardNumber": "5555555555554444",
"expirationDate": "2023-08"
}
}
},
{
"customerType": "individual",
"billTo": {
"firstName": "John",
"lastName": "Smithberg",
"address": "42 Main Street",
"city": "Townsville",
"state": "NJ",
"zip": "12345",
"phoneNumber": "800-555-1234"
},
"payment": {
"creditCard": {
"cardNumber": "5105105105105100",
"expirationDate": "2023-09"
}
}
}
],
"shipToList": {
"firstName": "John",
"lastName": "Smith",
"address": "12345 Main Street",
"city": "Townsville",
"state": "NJ",
"zip": "12345",
"phoneNumber": "800-555-1234"
}
},
"validationMode": "liveMode"
}
}
Response JSON:
{
"customerProfileId": "1506322353",
"customerPaymentProfileIdList": [
"1505667207",
"1505667208"
],
"customerShippingAddressIdList": [
"1505655763"
],
"validationDirectResponseList": [
"1,1,1,This transaction has been approved.,A2FD5O,Y,40023515435,none,Test transaction for ValidateCustomerPaymentProfile.,0.00,CC,auth_only,52353345,John,Smith,,12345 Main Street,Townsville,NJ,12345,,800-555-1234,,user#example.com,,,,,,,,,0.00,0.00,0.00,FALSE,none,32573C7D03376A9052AACA73835EDAEF,P,2,,,,,,,,,,,XXXX4444,MasterCard,,,,,,,,,,,,,,,,,",
"1,1,1,This transaction has been approved.,AO13Y1,Y,40023515436,none,Test transaction for ValidateCustomerPaymentProfile.,0.00,CC,auth_only,52353345,John,Smithberg,,42 Main Street,Townsville,NJ,12345,,800-555-1234,,user#example.com,,,,,,,,,0.00,0.00,0.00,FALSE,none,5B937D29D29F261776859B50DC1C3CF6,P,2,,,,,,,,,,,XXXX5100,MasterCard,,,,,,,,,,,,,,,,,"
],
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}

Ember Serialize 'ID'

I'm making an API call in Ember and the API I'm hitting is returning some JSON with 'ID' capitalized, it seems Ember is looking for lowercase 'id.' Everything else should work, so how would I serialize just this one piece of JSON in this instance?
See JSON below.
{
"ID": 2,
"name": "Main Menu",
"slug": "main-menu",
"description": "",
"count": 4,
"items": [
{
"id": 11,
"order": 1,
"parent": 0,
"title": "Contact",
"url": "http://localhost:8888/contact/",
"attr": "",
"target": "",
"classes": "",
"xfn": "",
"description": "",
"object_id": 7,
"object": "page",
"object_slug": "contact",
"type": "post_type",
"type_label": "Page"
},
{
"id": 12,
"order": 2,
"parent": 0,
"title": "About",
"url": "http://localhost:8888/about/",
"attr": "",
"target": "",
"classes": "",
"xfn": "",
"description": "",
"object_id": 5,
"object": "page",
"object_slug": "about",
"type": "post_type",
"type_label": "Page",
"children": [
{
"id": 21,
"order": 3,
"parent": 12,
"title": "About Us – Sub",
"url": "http://localhost:8888/about/about-us-sub/",
"attr": "",
"target": "",
"classes": "",
"xfn": "",
"description": "",
"object_id": 9,
"object": "page",
"object_slug": "about-us-sub",
"type": "post_type",
"type_label": "Page"
}
]
},
{
"id": 13,
"order": 4,
"parent": 0,
"title": "Home",
"url": "http://localhost:8888/home/",
"attr": "",
"target": "",
"classes": "",
"xfn": "",
"description": "",
"object_id": 2,
"object": "page",
"object_slug": "home",
"type": "post_type",
"type_label": "Page"
}
],
"meta": {
"links": {
"collection": "http://localhost:8888/wp-json/wp/v2/menus/",
"self": "http://localhost:8888/wp-json/wp/v2/menus/2"
}
}
}
You can define primaryKey: 'ID' by creating model specific serializer. read more for info https://guides.emberjs.com/v2.13.0/models/customizing-serializers/#toc_ids