Read Specific Character from NSSTRING and save them in NSDictionary (LinkedIn Api) - objective-c

I am using Linkedin Api in my Iphone App.I want to read the Connection Names and their Profession.In First Step I read the user name and Professional by using the Following Api.
http://api.linkedin.com/v1/people/~
It return the following String and I convert that string in to NSDictionary .Its Work Fine.
====================================
coming string is equql to {
"headline": "Computer Software Professional",
"lastName": "Ahmed",
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=86794265&authToken=ZBFd&authType=name&trk=api*a135617*s143990*"},
"firstName": "Umair"
}
========================================
Nsstring to NSDictionary conversion:-
Data coming from LinkedIn site
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(#"coming string is equql to %#",responseBody);
NSDictionary *profile = [responseBody objectFromJSONString];
[responseBody release];
if ( profile )
{
name.text = [[NSString alloc] initWithFormat:#"%# %#",
[profile objectForKey:#"firstName"], [profile objectForKey:#"lastName"]];
headline.text = [profile objectForKey:#"headline"];
}
The Above code Work Fine.
But when i use Connection Api.(For Linkedin Friends)
http://api.linkedin.com/v1/people/~/connections
I receive the following response in String.
========================================================================================
coming string is equql to {
"values": [
{
"headline": "--",
"id": "jrzlnzmKgH",
"lastName": "ahmad",
"pictureUrl": "http://media.linkedin.com/mpr/mprx/0_7bH7Ex4_zD3EJFYkDFRKEjehBacbMF0kD8prEjV0eIiBQ_HXiT4_XgmAM8BZVhOemkol5sXLbyGk",
"location": {
"name": "United Arab Emirates",
"country": {"code": "ae"}
},
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=87979190&authToken=RO5n&authType=name&trk=api*a135617*s143990*"},
"apiStandardProfileRequest": {
"headers": {
"values": [{
"name": "x-li-auth-token",
"value": "name:RO5n"
}],
"_total": 1
},
"url": "http://api.linkedin.com/v1/people/jrzlnzmKgH"
},
"firstName": "junaid"
},
{
"headline": "Field Testing Engineer at SENSYS",
"id": "iZbYn6whQT",
"lastName": "Ali Ayub",
"location": {
"name": "Pakistan",
"country": {"code": "pk"}
},
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=66010848&authToken=k_Wj&authType=name&trk=api*a135617*s143990*"},
"apiStandardProfileRequest": {
"headers": {
"values": [{
"name": "x-li-auth-token",
"value": "name:k_Wj"
}],
"_total": 1
},
"url": "http://api.linkedin.com/v1/people/iZbYn6whQT"
},
"industry": "Government Administration",
"firstName": "Prince"
},
{
"headline": "Student at comsats",
"id": "AZtfwY31D2",
"lastName": "Anwar",
"location": {
"name": "Pakistan",
"country": {"code": "pk"}
},
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=106573059&authToken=4_ll&authType=name&trk=api*a135617*s143990*"},
"apiStandardProfileRequest": {
"headers": {
"values": [{
"name": "x-li-auth-token",
"value": "name:4_ll"
}],
"_total": 1
},
"url": "http://api.linkedin.com/v1/people/AZtfwY31D2"
},
"industry": "Computer Networking",
"firstName": "Irfan"
},
{
"headline": "WiMAX RF Planning Engineer at IACGRP",
"id": "ERjOSiKbPo",
"lastName": "Arsil",
"pictureUrl": "http://media.linkedin.com/mpr/mprx/0_T_Ic9x0GWkhvZ7R13LHX9juCdb-ZsoI1iC0e9pDY9C6e5mpPD5RRZyMKFdtbJDo088ddJU1s5_py",
"location": {
"name": "Pakistan",
"country": {"code": "pk"}
},
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=35285050&authToken=ouYS&authType=name&trk=api*a135617*s143990*"},
"apiStandardProfileRequest": {
"headers": {
"values": [{
"name": "x-li-auth-token",
"value": "name:ouYS"
}],
"_total": 1
},
"url": "http://api.linkedin.com/v1/people/ERjOSiKbPo"
},
=====================================================
Now I want to convert it in to NsDictionary With key Value Like Firstname,Lastname etc.How can I do This.
Thanks in Advance

You need to use a JSON library for iPhone. One of them is the TouchJSON library, you can see this question to learn more.

Use Json Libraray for Retreive your Values.Its so Simple.Thanks

Related

Swagger API having different response with the change of Optional Parameters

I am trying to create the OAS Swagger documentation for an existing API where the response for the API is changing on the basis of Query parameter. I am struggling to document this in a developer friendly way, so need some assistance. Below is the complete scenario for your reference.
EndPoint 1 : /order?expand=false
/order?expand=false
{
"orderNo": "12345",
"orderDetail": "Description of Order",
"orderMarket": {
"id": "UK"
},
"brandOrderStatus": {
"id": "LLA"
}
}
Endpoint 2 : /order?expand=true
{
"orderNo": "12345",
"orderDetail": "Description of Order",
"orderMarket": {
"id": "UK",
"descr": "United Kingdom",
"lang": "en-GB"
},
"brandOrderStatus": {
"id": "LLA",
"descr": "Some Status Description",
"lang": "en-GB"
}
}
Endpoint 3 : /order?expand=true&include=feature
{
"orderNo": "12345",
"orderDetail": "Description of Order",
"orderMarket": {
"id": "UK",
"descr": "United Kingdom",
"lang": "en-GB"
},
"brandOrderStatus": {
"id": "LLA",
"descr": "Some Status Description",
"lang": "en-GB"
}
"_embedded": {
"features": [
{
"id": "AJS",
"type": "FeatureType",
"descr": "FeatureDescription",
"prices": [
{
"type": "msrpNetPrice",
"amount": 0.00,
"currency": "GBP"
}
],
"group": "null"
}
]
}
}
I tried using OneOf, but don't really think that will work in this case as the structure is changing with every optional parameter.
Any thoughts as how this can be documented in Swagger documentation ? Or any other idea to get this documented.

Querying/flattening multi-level nested JSON in Cosmos DB when array name is random on one level deep down

I would like to get some help to write a query to get a flat JSON to feed Power BI.
The data store is a Cosmos DB container with JSON. The structure is fixed.
The example JSON stucture is this:
"orderid": "999888777",
"name": "dwayne.johnson",
"mainData": {
"giftData": {
"name": "Rocketship",
"giftDetails": {
"**123456789**": {
"boxInfo": [
{
"name": "Leonardo Da Vinci Big Box",
"city": "London",
"country": "United Kingdom",
"currency": "EUR",
"price": 99.43,
}
],
"colorScheme": [
{
"name": "Red Apple Delight",
"code": "123AAA",
}
],
"CourierInfo": [
{
"name": "UPS",
"code": "BBBA333",
}
],
"orderid": "444333434",
"name": "chris.rock",
"mainData": {
"giftData": {
"name": "Junglemaster XXL",
"giftDetails": {
"**32432423424**": {
"boxInfo": [
{
"name": "Gerba Tool Big O",
"city": "München",
"country": "Germany",
"currency": "EUR",
"price": 103.22,
}
],
"colorScheme": [
{
"name": "Green Mix",
"code": "999DDD",
}
],
"CourierInfo": [
{
"name": "GLS",
"code": "CCCGV3",
}
],
I would like to get to following output:
orderid
currency*
price**
999888777
EUR
99.43
444333434
EUR
103.22
*The path would be giftData.giftDetails.123456789 or 32432423424 or any random.boxInfo.currency
**The path would be giftData.giftDetails.123456789 or 32432423424 or any random.boxInfo.price
The question is how can I select the currency and price info 4 levels deep, when the container array name is a random number (in bold)?
Thank you very much for your time and help!

Issue when sending Query with Arabic characters through API

I can't send Query with Arabic characters through API. I am trying to send the query from CS-Cart to Quickbooks Online.
I tried to send the query using the arabic letters as the following:
select * from Customer Where DisplayName = 'احمد عبدالعزيز'
it returns:
{
"responseHeader": {
"status": 400,
"message": "Bad Request",
"intuitTid": "2dbec1fd-5dc1-3a14-4a12-7c338db0ee2a",
"realmID": "123146420719144"
},
"response": {
"Fault": {
"Error": [
{
"Message": "Error parsing query",
"Detail": "QueryParserError: Invalid content. Lexical error at line 1, column 45. Encountered: \"\\u0627\" (1575), after : \"\\'\"",
"code": "4000"
}
],
"type": "ValidationFault"
},
"time": "2019-07-04T07:09:03.026-07:00"
}
}
And if I try it after encoding the name and send the query as the following:
select * from Customer Where DisplayName = '%D8%A7%D8%AD%D9%85%D8%AF+%D8%B9%D8%A8%D8%AF%D8%A7%D9%84%D8%B9%D8%B2%D9%8A%D8%B2'
it returns nothing:
{
"QueryResponse": {},
"time": "2019-07-04T07:09:42.698-07:00"
}
I am expecting to get like:
{
"QueryResponse": {
"Customer": [
{
"Taxable": false,
"BillAddr": {
"Id": "924",
"Country": "Saudi Arabia"
},
"ShipAddr": {
"Id": "925",
"Country": "Saudi Arabia"
},
"Job": false,
"BillWithParent": false,
"Balance": 157.5,
"BalanceWithJobs": 157.5,
"CurrencyRef": {
"value": "SAR",
"name": "Saudi Riyal"
},
"PreferredDeliveryMethod": "None",
"IsProject": false,
"domain": "QBO",
"sparse": false,
"Id": "577",
"SyncToken": "0",
"MetaData": {
"CreateTime": "2019-07-01T06:37:32-07:00",
"LastUpdatedTime": "2019-07-01T06:37:33-07:00"
},
"GivenName": "Ramil",
"FamilyName": "Gilaev",
"FullyQualifiedName": "Ramil Gilaev",
"DisplayName": "Ramil Gilaev",
"PrintOnCheckName": "Ramil Gilaev",
"Active": true,
"PrimaryPhone": {
"FreeFormNumber": "123456789"
}
}
],
"startPosition": 1,
"maxResults": 1
},
"time": "2019-07-05T02:12:35.562-07:00"
}
Also I noticed even if the Query is in English name, it results the same.
select * from Customer Where DisplayName = 'Ahmed Al-Khuraisir'
it results:
{
"QueryResponse": {},
"time": "2019-07-05T03:31:11.149-07:00"
}
Please check attached images.
Screenshot 1
Screenshot 2

How to process payments with service fee being deducted in Visa Cybersource Payments API?

I have an app that I would like to add payment processing similar to Amazon payment processing into it where sub-merchants get paid by customers with service fee being deducted, I can see in https://developer.visa.com/capabilities/cybersource/reference#cybersource__cybs_payments_v2__v2__process_a_payment the following request body but there is no field in request body to specify a service fee:
{
"clientReferenceInformation": {
"code": "TC588171_3"
},
"processingInformation": {
"commerceIndicator": "internet"
},
"aggregatorInformation": {
"subMerchant": {
"cardAcceptorID": "1234567890",
"country": "US",
"phoneNumber": "650-432-0000",
"address1": "900 Metro Center",
"postalCode": "94404-2775",
"locality": "Foster City",
"name": "Visa Inc",
"administrativeArea": "CA",
"region": "PEN",
"email": "test#cybs.com"
},
"name": "V-Internatio",
"aggregatorID": "123456789"
},
"orderInformation": {
"billTo": {
"country": "US",
"lastName": "VDP",
"address2": "Address 2",
"address1": "201 S. Division St.",
"postalCode": "48104-2201",
"locality": "Ann Arbor",
"administrativeArea": "MI",
"firstName": "RTS",
"phoneNumber": "999999999",
"district": "MI",
"buildingNumber": "123",
"company": "Visa",
"email": "test#cybs.com"
},
"amountDetails": {
"totalAmount": "102.21",
"currency": "USD"
}
},
"paymentInformation": {
"card": {
"expirationYear": "2031",
"number": "5555555555554444",
"securityCode": "123",
"expirationMonth": "12",
"type": "002"
}
}
}
Is there a way or a workaround to get a service fee deducted?
Service fees go in the orderInformation block. Like this:
"orderInformation": {
"amountDetails": {
"totalAmount": "102.21",
"currency": "USD",
"serviceFeeAmount": "3.00"
},
There are a few prerequisites to using service fees. One of which you must be using First Data as your processor. For more details check this documentation.

eBay API issues - cannot publish an offer

All of the following is being performed in eBay's API sandbox.
I am attempting to list an item by using the inventory API. Specifically, I have created an inventory item and a relevant offer for that item. When I make a POST request to the publish offer endpoint, I get the following error:
{
"errors": [
{
"errorId": 25016,
"domain": "API_INVENTORY",
"subdomain": "Selling",
"category": "REQUEST",
"message": "The title value is invalid. Seller Provided Title Value is missing."
},
{
"errorId": 25002,
"domain": "API_INVENTORY",
"subdomain": "Selling",
"category": "REQUEST",
"message": "A user error has occurred. The duration \"GTC\" day(s) is not available for this listing type, or invalid for category \"49996\".",
"parameters": [
{
"name": "0",
"value": "GTC"
},
{
"name": "1",
"value": "49996"
}
]
}
]
}
I can't see any reference in any of the API documentation to a "Seller Provided Title". The duration error is also confusing as the API says it only supports "GTC" listings. The product has a title so it must be in reference to something else.
My inventory item is as follows:
{
"sku": "13725",
"product": {
"title": "Harley Davidson bike",
"aspects": {
"Year": [
"2016"
],
"Model": [
"Road Glide Special"
],
"Manufacurer": [
"Harley-Davidson®"
],
"Type": [
"Touring"
],
"For Sale By": [
"Dealer"
],
"Vehicle Title": [
"Clear"
],
"Mileage": [
"13393"
],
"VIN (Vehicle Identification Number)": [
"1HD1KTM10GB627264"
],
"Color": [
"Black Quartz"
]
},
"description": "Item description goes here",
"imageUrls": [
"https://dw4i9za0jmiyk.cloudfront.net/2018/01/12/pre_ic60e5df584b870c3d2a55c86800eede_70618b24eb08.jpg"
]
},
"condition": "USED_EXCELLENT",
"availability": {
"pickupAtLocationAvailability": [
{
"quantity": 1,
"merchantLocationKey": "425",
"availabilityType": "IN_STOCK",
"fulfillmentTime": {
"value": 1,
"unit": "DAY"
}
}
]
}
}
And my offer object is as follows:
{
"offerId": "5852159010",
"sku": "13725",
"marketplaceId": "EBAY_MOTORS",
"format": "FIXED_PRICE",
"availableQuantity": 0,
"pricingSummary": {
"price": {
"value": "18294.0",
"currency": "USD"
}
},
"listingPolicies": {
"paymentPolicyId": "5807565000",
"fulfillmentPolicyId": "5806186000"
},
"categoryId": "49996",
"merchantLocationKey": "425",
"tax": {
"applyTax": false
},
"status": "UNPUBLISHED",
"eBayPlusEligible": false
}
I had similar issues on sandbox, and came to the conculsion it was broken.
They also have some limits on only certain categories working.
Have you tried it agains the live API, I have found this to be far more reliable, ignoring the fact doing development work live is dangerous!
For your info here is my working code offer:
inventory_template = {
"availability": {
"shipToLocationAvailability": {
"quantity": product.quantity_available
}
},
"condition": "NEW",
"product": {
"aspects": {spec.name: [spec.value] for spec in product.specifics},
"brand": product.product_brand,
"description": product.product_description,
"imageUrls": [
"https://ebay.mydomain.co.uk/{}".format(img.image_link) for img in product.images],
"mpn": product.product_mpn,
"title": product.product_title,
"upc": [
product.product_upc,
],
"ean": [
product.product_ean,
],
# "epid": "string"
},
"sku": sku,
}
offer_body = {
"availableQuantity": offer.available_quantity,
"categoryId": offer.category_id,
"listingDescription": html,
"listingPolicies": {
"paymentPolicyId": offer.payment_policy_id,
"returnPolicyId": offer.return_policy_id,
"fulfillmentPolicyId": offer.fulfillment_policy_id,
},
"merchantLocationKey": offer.merchant_location_key,
"pricingSummary": {
"price": {
"value": offer.summary_price_value,
"currency": offer.summary_price_currency
}
},
"sku": offer.sku,
"marketplaceId": offer.marketplace_id,
"format": offer.format
}
the offer.available_quantity etc are items from my database, its the structure I'm showing.