What are valid contents of the "address_from" field? Is it context sensitive? - shippo

In various places in the API documentation, I see where I can pass a JSON object with address information:
https://goshippo.com/docs/first-shipment
or using an address identifier:
https://goshippo.com/docs/manifests
Can I use either JSON or an identifier for the address_from field anytime?

You can use the address object_id in place of the full address object for any address_to or address_from field.
You can see at https://goshippo.com/docs/reference#shipments-create that you can provide either a string or an object to create the shipment.

Related

Dynamically determine header based on GET parameters

For one of our REST webservices, we have implemented a GET method having the following URI:
http://ourcompany.com/doSomething/getSomething?parameter1=ABC&parameter2=123
Now, one of the headers required for security is the following
userName: ABC123, derived from concatenating the values of parameter1 and parameter2
My question is, how, in SoapUI (preferably via the SoapUI interface, itself), do I dynamically generate this header value from the parameter values supplied in the GET method?
You can create test case level custom properties instead of string value for the parameters which you have currently, say
name as PROPERTY1, and value as ABC
name as PROPERTY2, and value as 123
In the GET request step, provide values as Property Expansion, say
${#TestCase#PROPERTY1}, ${#TestCase#PROPERTY2} respectively for the parameters.
Coming to the headers, define the required header and use Property Expansion again. i.e., header name as userName and value as ${#TestCase#PROPERTY1}${#TestCase#PROPERTY2}
Hope the above should resolve the issue.

User address sub fields not showing in userinfo response

I have added a mapper to my client with a mapper type of 'User Address' and enabled the 'Add to userinfo' option
I have then set an address attribute on my user as follows:
When making a request to the userinfo endpoint I just get back an empty address object:
Have I missed out something here? We are using keycloak 3.2.1 also.
Thanks
Your user's attributes must be passed as single key/value pairs , not as full JSON object.
And the values in the mapper must be filled in as well :

REST Resource route naming for get and ResourceByID and ResourceByName

I am trying to write 2 Rest GET methods.
Get user by Id
Get user by userName.
I need to know if there is any resource naming convention for this. Both my id and username are strings.
I came up with:
/api/{v}/users/{userid}
/api/{v}/users/username/{username}
However, 2) doesn't seem correct and if I change 2) to /api/{v}/users/{username}, I am mapping to 1) as both id and username are strings. Or is it considered acceptable to use /api/{v}/userbyName/{username}?
How should I name my resource route in case 2) ?
First of all: https://vimeo.com/17785736 (15 minutes which will solve all your questions)
And what is unique? Is the username unique or only the id or both are unique?
There is a simple rule for all that:
/collection/item
However, 2) doesn't seem correct and if I change 2) to /api/{v}/users/{username}, I am mapping to 1) as both id and username are strings.
If your item can be identified with an id and also with an unique username - it doesn't matter if it's the username or the id - simply look for both (of course your backend needs to handle that) and retrieve it.
According to your needs this would be correct:
/api/{v}/users/{userid}
/api/{v}/users/{username}
but I would choose only to use: /api/{v}/users/{userid} and filter by username only with a query parameter (description for that down there below)
Also will I break any rules if I come up with
/api/{v}/userbyName/{username}
Yes - /api/{v}/userbyName/{username} will break the rule about /collection/item because userByName is clearly not a collection it would be a function - but with a real restful thinking api there is no function in the path.
Another way to get the user by name would be using a filter/query paramter - so the ID will be available for the PathParameter and the username only as filter. which than would look like this:
/api/{v}/users/?username={username}
This also don't break any rules - because the query parameter simply filters the whole collection and retrieves only the one where username = username.
How should I name my resource route in case 2) ?
Your 2) will break a rule - so I can't/won't suggest you a way to do it like this.
Have a look at this: https://vimeo.com/17785736 this simple presentation will help you a lot about understanding rest.
Why would you go this way?
Ever had a look at a javascript framework like - let's say ember. (Ember Rest-Adapter). If you follow the idea described up there and maybe also have a look at the json format used by ember and their rest adapter - you can make your frontend developer speed up their process and save a lot of money + time.
By REST you send back links, which can contain URI templates. For example: /api/{v}/users/{userid} in your case, where v and userid are template variables. Since the URI structure does not matter from a client perspective you can use whatever structure you want. Ofc. it is more convenient to use nice and short URIs, because it is easier to write the routing with them.
According to the URI standard the path contains the hierarchical while the query contains the non-hierarchical part of the URI, but this is just a loose constraint, in practice ppl use both one.
/api/{v}/users/name/{username}
/api/{v}/users/name:{username}
/api/{v}/users?name="{username}"
Ofc. you can use a custom convention, for example I use the following:
I don't use plural resource name by collections
I end collection path with slash
I use slash by reducing a collection to sub-collections or individual items
I don't use slash to give the value of a variable in the path, I use colon instead
I use as few variables and as short URI as I can
I use query by reducing a collection to sub-collections especially by defining complex filters with logical operators
So in you case my solution would be
/api/{v}/user/
/api/{v}/user/name:{username}
/api/{v}/user/{userid}
and
/api/{v}/user/?firstName="John"
/api/{v}/user/?firstName="John|Susan"&birthYear="1980-2005"
or
/api/{v}/user/firstName:John/
/api/{v}/user/firstName:John|Susan/birthYear:1980-2005/
etc...
But that's just my own set of constraints.
Each resource should have a unique URI.
GET /users/7
{
"id": 7,
"username": "jsmith",
"country": "USA"
}
Finding the user(s) that satisfy a certain predicate should be done with query parameters.
GET /users?username=jsmith
[
"/users/7"
]

Sharepoint URL to reference a lookup

I have two SharePoint lists used for Support case management. The first list contains Case Numbers and information about the case. The second list contains exhibits that support the case itself.
We have a convention that the Case Number is a String supplied by the worker, ex 20150205-001. When the exhibits are joined to the Case it is through a Lookup. I want the Exhibit ID, a String, to be of the form Case Number + _[A-Z] -- and be auto-assigned.
I want to use a Workflow (MS Sharepoint Designer 2013) to assign the Exhibit ID. The problem I face is that I cannot get the actual Case Number from the Lookup. The closest I have gotten so far is to get the ID (1, 2, etc) but not the actual String value represented.
Tried working with the following URL:
http://[mySiteURL]/_api/web/lists/getbytitle([listName])/items?$select=Title,Case/Id&$expand=Case/Id&$filter=Case/Id%20eq%2020150205%45001
substituted ascii: $filter=Case/ID eq 20150205-001
without the filter I get all list items (understandably) but the filter does not work properly because the ID is not the actual lookup value.
This is a SPD 2013 limitation. You have to use a web service call from within Designer to get the specifics of a lookup column from SharePoint. You make a REST call ad then parse the JSON response for the specific data from the lookup column. It gives you access to all of the columns from the list item that you looked up:
Build {...} Dictionary (Output to Variable: requestHeader )
Call [%Workflow Context:Current Site URL%]... HTTP web service with Variable: Request (ResponseContent to Variable: PoleIDData |ResponseHeaders to Variable: dictionary |ResponseStatusCode to Variable: responseCode )
Get d/Pole_x0020_ID from Variable: PoleIDData (Output to Variable: PoleID )
Set Name to Variable: PoleID
Your actual web service call will be formatted like this:
[%Workflow Context:Current Site URL%]/_api/web/lists/GetByTitle('List Name')/Items([%Current Item:ID%])/LookupColumnNameOnOtherList
Sorry for the formatting, I would post a screenshot but I cannot.
This article is good for showing you some of the other specifics about formatting your HTTP Request, especially the Request Headers which must be setup right.
http://www.fiechter.eu/Blog/Post/37/SharePoint-2013--HTTP-Web-Service-Action---Use-Managed-Metadata-as-Text-in-Workflow

How to identify account type

I get list of accounts by using getAccount() and discoverAndAddAccounts(). For each account type (CREDIT, LOAN, etc...), there are specific set of fields that I need to access. For example, I want to access creditMaxAmount field of CreditAccount. However, i dont seem to find a way to identify "type" of a given account object.
In summary, given output of above mentioned functions, how do I identify account type in order to access fields specific to that account type.
The type of account is identified by the Account header.
See https://ipp.developer.intuit.com/index.php?title=0010_Intuit_Partner_Platform/0020_Aggregation_%26_Categorization_Apps/AggCat_API/0020_API_Documentation/0050getLoginAccounts for the response XML.
As you can see there is InvestmentAccount, CreditAccount, BankingAccount, LoanAccount, ..., and OtherAccount.
If an account shows up as OtherAccount, that means that it has not been set to a specific account. You can use updateAccountType to set the type of account it should be.
<ns8:AccountList xmlns="http://schema.intuit.com/platform/fdatafeed/account/v1"
xmlns:ns2="http://schema.intuit.com/platform/fdatafeed/creditaccount/v1"
xmlns:ns3="http://schema.intuit.com/platform/fdatafeed/rewardsaccount/v1"
xmlns:ns4="http://schema.intuit.com/platform/fdatafeed/bankingaccount/v1"
xmlns:ns5="http://schema.intuit.com/platform/fdatafeed/investmentaccount/v1"
xmlns:ns6="http://schema.intuit.com/platform/fdatafeed/otheraccount/v1"
xmlns:ns7="http://schema.intuit.com/aggregation/loanaccount/v1"
xmlns:ns8="http://schema.intuit.com/platform/fdatafeed/accountlist/v1">
<ns7:**LoanAccount**>
<accountId>75000033014</accountId>
<accountNumber>9900009994</accountNumber>
<accountNickname>My Military Loan</accountNickname>
<displayPosition>5</displayPosition>
<institutionId>0</institutionId>
<description>Description</description>
<balanceAmount>90227.2</balanceAmount>
<aggrSuccessDate>2012-02-27T23:20:13.651-08:00</aggrSuccessDate>
<aggrAttemptDate>2012-02-27T23:20:13.651-08:00</aggrAttemptDate>
<aggrStatusCode>0</aggrStatusCode>
<currencyCode>USD</currencyCode>
<ns7:loanType>**MILITARY**</ns7:loanType>
There is no direct way to identify the Account type, the getBankingAccountsAndCreditAccountsAndLoanAccounts() method will return the Accounts, and you would need to check the Object type in order to determine the Account type.