import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
ups: {
type: "app",
app: "ups",
}
},
async run({steps, $}) {
const data = {
"XAVRequest": {
"AddressKeyFormat": {
"ConsigneeName": "RITZ CAMERA CENTERS-1749",
"BuildingName": "Innoplex",
"AddressLine": [
"26601 ALISO CREEK ROAD",
"STE D",
"ALISO VIEJO TOWN CENTER"
],
"Region": "ROSWELL,GA,30076-1521",
"PoliticalDivision2": "ALISO VIEJO",
"PoliticalDivision1": "CA",
"PostcodePrimaryLow": "92656",
"PostcodeExtendedLow": "1521",
"Urbanization": "porto arundal",
"CountryCode": "US"
}
}
}
return await axios($, {
method: "post",
url: `https://onlinetools.ups.com/api/addressvalidation/v2/1`,
headers: {
Authorization: `Bearer ${this.ups.$auth.oauth_access_token}`,
"content-type": `application/json`,
},
params: {
maximumcandidatelistsize: `1`,
},
data,
})
},
})
UPS uses OAuth authentication. When you connect your UPS account, Pipedream will open a popup window where you can sign into UPS and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any UPS API.
Pipedream requests the following authorization scopes when you connect your account:
GET
https://onlinetools.ups.com/security/v1/oauth/authorize
?
client_id={{custom_fields.client_id}}
&
redirect_uri={{oauth.redirect_uri}}
&
state={{oauth.state}}
&
response_type=code
POST
https://onlinetools.ups.com/security/v1/oauth/token
content-type: application/x-www-form-urlencoded
accept: application/json
redirect_uri={{oauth.redirect_uri}}
&
grant_type=authorization_code
&
code={{oauth.code}}
POST
https://onlinetools.ups.com/security/v1/oauth/refresh
content-type: application/x-www-form-urlencoded
accept: application/json
grant_type=refresh_token
&
refresh_token={{oauth.refresh_token}}