POST | /account/register | Create a new account |
---|
import Foundation
import ServiceStack
// @DataContract
public class RegisterAccount : BaseRequest
{
// @DataMember
public var request:RegisterAccountRequest
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case request
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
request = try container.decodeIfPresent(RegisterAccountRequest.self, forKey: .request)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if request != nil { try container.encode(request, forKey: .request) }
}
}
// @DataContract
public class BaseRequest : IBaseRequest, Codable
{
/**
* The authentication credentials
*/
// @DataMember
// @ApiMember(Description="The authentication credentials", IsRequired=true, ParameterType="header, body")
public var authentication:Authentication
required public init(){}
}
// @DataContract
public class Authentication : Codable
{
/**
* The API User ID provided by us when you signed up to use our API
*/
// @DataMember
// @ApiMember(Description="The API User ID provided by us when you signed up to use our API", IsRequired=true, ParameterType="header, body")
public var apiUserId:String
/**
* The API User Key provided by us when you signed up to use our API
*/
// @DataMember
// @ApiMember(Description="The API User Key provided by us when you signed up to use our API", IsRequired=true, ParameterType="header, body")
public var apiUserKey:String
required public init(){}
}
public class RegisterAccountRequest : Codable
{
/**
* The desired login username for the account
*/
// @ApiMember(Description="The desired login username for the account", IsRequired=true)
public var username:String
/**
* The password for account login
*/
// @ApiMember(Description="The password for account login", IsRequired=true)
public var password:String
/**
* The contact email address for the account holder
*/
// @ApiMember(Description="The contact email address for the account holder", IsRequired=true)
public var email:String
/**
* The full legal name of the account holder
*/
// @ApiMember(Description="The full legal name of the account holder", IsRequired=true)
public var fullName:String
/**
* The registered name of the company associated with this account
*/
// @ApiMember(Description="The registered name of the company associated with this account", IsRequired=true)
public var companyName:String
/**
* The primary contact phone number of the company
*/
// @ApiMember(Description="The primary contact phone number of the company", IsRequired=true)
public var companyPhone:String
/**
* The first line of the company’s address (e.g., street name and number)
*/
// @ApiMember(Description="The first line of the company’s address (e.g., street name and number)", IsRequired=true)
public var address1:String
/**
* The second line of the company’s address (optional)
*/
// @ApiMember(Description="The second line of the company’s address (optional)")
public var address2:String
/**
* The third line of the company’s address (optional)
*/
// @ApiMember(Description="The third line of the company’s address (optional)")
public var address3:String
/**
* The city where the company is located (optional)
*/
// @ApiMember(Description="The city where the company is located (optional)")
public var city:String
/**
* The postal or ZIP code of the company’s address
*/
// @ApiMember(Description="The postal or ZIP code of the company’s address", IsRequired=true)
public var postcode:String
/**
* The country where the company is registered
*/
// @ApiMember(Description="The country where the company is registered", IsRequired=true)
public var country:String
/**
* The classification of the company (e.g., LLC, Corporation, Sole Proprietorship)
*/
// @ApiMember(Description="The classification of the company (e.g., LLC, Corporation, Sole Proprietorship)", IsRequired=true)
public var companyType:String
/**
* The industry sector the company operates in
*/
// @ApiMember(Description="The industry sector the company operates in", IsRequired=true)
public var companyIndustry:String
/**
* The trade body, network, or affiliation the company is a member of (if applicable)
*/
// @ApiMember(Description="The trade body, network, or affiliation the company is a member of (if applicable)")
public var companyNetwork:String
/**
* Indicates agreement to the terms and conditions (required)
*/
// @ApiMember(Description="Indicates agreement to the terms and conditions (required)", IsRequired=true)
public var agreeToTerms:Bool
/**
* Indicates agreement to the data protection statement (required)
*/
// @ApiMember(Description="Indicates agreement to the data protection statement (required)", IsRequired=true)
public var agreeToDataProtection:Bool
/**
* Indicates consent to be contacted (optional)
*/
// @ApiMember(Description="Indicates consent to be contacted (optional)")
public var agreeToContact:Bool
/**
* Indicates agreement to the privacy policy (required)
*/
// @ApiMember(Description="Indicates agreement to the privacy policy (required)", IsRequired=true)
public var agreeToPrivacy:Bool
/**
* An optional voucher code for discounts or promotions
*/
// @ApiMember(Description="An optional voucher code for discounts or promotions")
public var voucherCode:String
/**
* An optional code that grants access to certain features or subscriptions
*/
// @ApiMember(Description="An optional code that grants access to certain features or subscriptions")
public var accountActivationCode:String
/**
* The company's VAT registration number (if applicable)
*/
// @ApiMember(Description="The company's VAT registration number (if applicable)")
public var vatNumber:String
/**
* The country where the company is VAT-registered
*/
// @ApiMember(Description="The country where the company is VAT-registered")
public var vatCountry:String
required public init(){}
}
// @DataContract
public class RegisterAccountResponse : Codable
{
/**
* The response data
*/
// @DataMember
// @ApiMember(Description="The response data")
public var data:RegisterAccountData
required public init(){}
}
public class RegisterAccountData : BaseResponse
{
/**
* A unique identifier for the users API access
*/
// @ApiMember(Description="A unique identifier for the users API access")
public var apiUserId:String
/**
* A secure, randomly generated key used for API authentication
*/
// @ApiMember(Description="A secure, randomly generated key used for API authentication")
public var apiUserKey:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case apiUserId
case apiUserKey
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
apiUserId = try container.decodeIfPresent(String.self, forKey: .apiUserId)
apiUserKey = try container.decodeIfPresent(String.self, forKey: .apiUserKey)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if apiUserId != nil { try container.encode(apiUserId, forKey: .apiUserId) }
if apiUserKey != nil { try container.encode(apiUserKey, forKey: .apiUserKey) }
}
}
public class BaseResponse : IBaseDataResponse, IHasResponseStatus, Codable
{
/**
* The status of the response
*/
// @ApiMember(Description="The status of the response")
public var responseStatus:ResponseStatus
required public init(){}
}
public class ArrayOfResponseError : List<ResponseError>
{
required public init(){ super.init() }
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /account/register HTTP/1.1
Host: api.sanctionssearch.com
Accept: application/json
Content-Type: application/json
Content-Length: length
{"request":{"username":"String","password":"String","email":"String","fullName":"String","companyName":"String","companyPhone":"String","address1":"String","address2":"String","address3":"String","city":"String","postcode":"String","country":"String","companyType":"String","companyIndustry":"String","companyNetwork":"String","agreeToTerms":false,"agreeToDataProtection":false,"agreeToContact":false,"agreeToPrivacy":false,"voucherCode":"String","accountActivationCode":"String","vatNumber":"String","vatCountry":"String"},"authentication":{"apiUserId":"String","apiUserKey":"String"}}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"data":{"apiUserId":"String","apiUserKey":"String","responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}}