FORMAT: 1A

# Group Vectorapi
Group of all vectorapi-related resources.

## Subaccount

Originally Vendor was the Label account who have their own releases. But with the concept of Distributors from IODA,  the vendor no longer is an individual Label. Instead its a distributor that has several Labels under it. These labels under a distributor are called sub account.

## Index [/vectorapi/subaccount/index{?limit,access_token}]

Gets all subaccount list for DA, subaccount user & OA user, else self subaccount details. Non-Dist vendor cannot access it.

### Index [GET]

+ Parameters

    + limit  (number, `2`)
    + access_token (varchar, `some token`)
  
+ Request JSON Message
    
    + Headers

            Accept: application/json

+ Response 200 (application/json)

    + Body
{
  "envelope": {
    "header": {
      "apiVersion": "1.0",
      "baseUrl": "vapi.alpha.devorch.com",
      "httpStatusCode": 200
    },
    "request": "subaccount/index?params=vectorapi&subaccount&index&2&<some_token>&json",
    "response": {
      "subaccounts": [
        {
          "subaccountId": "1",
          "subaccountName": "Label One",
          "vendorId": "16055",
          "dateDeleted": null
        },
        {
          "subaccountId": "2",
          "subaccountName": "karenlabel",
          "vendorId": "16055",
          "dateDeleted": null
        }
      ],
      "paginationOption": {
        "limit": "2",
        "offset": 0,
        "pageNumber": 1,
        "totalRecords": "18227"
      },
      "sortOption": {
        "columnName": null,
        "orderBy": null
      },
      "totalRecords": "18227"
    }
  }
}


+ **Other Optional Parameters**

    + Pagination Options : limit, offset, pageNumber, totalRecords
    + Sort Options : columnName, orderBy
    + Parameter options : subaccountId,vendorId,activeUsersFlag(either 'Y' or 'N')


## GET [/vectorapi/subaccount{?id,access_token}]

Gets all the details for a particular subaccountId. DA can get any of its subaccount users details. Non-Dist vendor cannot access it.

+ Parameters

    + id (required,number, `100`) ... An unique identifier of the subaccount_id.
    + access_token (required,varchar, `some token`)


### Get [GET]

+ Request JSON Message
    
    + Headers

            Accept: application/json

+ Response 200 (application/json)
    + Body
{
  "envelope": {
    "header": {
      "apiVersion": "1.0",
      "baseUrl": "vapi.alpha.devorch.com",
      "httpStatusCode": 200
    },
    "request": "subaccount/get?params=vectorapi&subaccount&get&100&<some_token>&json",
    "response": {
      "subaccount": {
        "subaccountId": 100,
        "subaccountName": "Cuezone Records",
        "websiteUrl": "http://www.cuezonerecords.com",
        "myspaceUrl": "",
        "city": "Rockaway Park",
        "stateProvince": "1",
        "description": "jazz and rock... and more",
        "commissionOverride": 0.85,
        "dateDeleted": null,
        "vendor": {
          "vendorId": 18454,
          "company": "Synergy Distribution",
          "contactEmail": "digital@synergydistribution.com",
          "vendorName": "Synergy Distribution"
        },
        "genre": {
          "genreId": 8,
          "genreName": "Jazz"
        },
        "country": {
          "countryName": "USA",
          "isoCountryCode": "USA"
        },
        "soundscanCodes": []
      }
    }
  }
}


+ **Other Optional Parameters**

    + Required Parameters : id


## POST [/vectorapi/subaccount{?data,access_token}]

Create a new subaccount for current DA user. OA need to explicitly pass "vendor_id" part of data json.

### Post [POST]

+ Parameters

    + data (varchar, `{"subaccountName":"Test subaccount","genreId":"11", "websiteUrl":"www.newsubaccount2.com",                "myspaceUrl":"newsubaccount22", "city":"city1", "stateProvince":"state1", "isoCountryCode":"AUS","commissionOverride":"0.1", "contactEmail":"abc@theorchard.com"}`)
    + access_token (varchar, `some token`)

+ Request JSON Message
    
    + Headers

            Accept: application/json

+ Response 200 (application/json)

    + Body
{
  "subaccountId": 18233,
  "result": "success"
}


+ **Other Optional Parameters**

    + Required Parameters : subaccountName , contactEmail
    + Optional Parameters : genreId, websiteUrl, myspaceUrl, city, stateProvince, isoCountryCode, commissionOverride
    + Validation : genreId, isoCountryCode, commissionOverride


## PUT [/vectorapi/subaccount{?id,data,access_token}]

Edits a subaccount for current DA user. OA can edit any subaccount. "subaccountName" is not editable.

### Put [PUT]

+ Parameters

    + id (required,number,`18896`)
    + data (varchar, `{"vendorId":"16055","genreId":"11", "websiteUrl":"www.newsubaccount23.com","myspaceUrl":"newsubaccount23", "city":"city2","stateProvince":"state2", "isoCountryCode":"AUS","commissionOverride":"0.1","contactEmail":"abc12@theorchard.com"}`)
    + access_token (varchar, `some token`)

+ Request JSON Message
    
    + Headers

            Accept: application/json

+ Response 200 (application/json)

    + Body
{
  "subaccountId": 18896,
  "result": "success"
}


## PUT [/vectorapi/subaccount{?id,data,access_token}]

Reactivate the subaccount user.

### Put [PUT]

+ Parameters

    + id (required,number,`18896`)
    + data (varchar, `{"dateDeleted":"NULL"}`)
    + access_token (varchar, `some token`)

+ Request JSON Message
    
    + Headers

            Accept: application/json

+ Response 200 (application/json)

    + Body
{
  "subaccountId": 18896,
  "result": "success"
}

+ **Other Optional Parameters**

    + Required Parameters : id 
    + Optional Parameters : subaccountName,genreId, websiteUrl, myspaceUrl, city, stateProvince, isoCountryCode, commissionOverride,contactEmail
    + Validation : genreId, isoCountryCode, commissionOverride


## Delete [/vectorapi/subaccount{?id,access_token}]

### Delete [DELETE]

+ Parameters

    + id (required, number, `18897`)
    + access_token (required ,varchar, `some token`)

+ Request JSON Message
    
    + Headers

            Accept: application/json

+ Response 200 (application/json)

    + Body
{
  "envelope": {
    "header": {
      "apiVersion": "1.0",
      "baseUrl": "vapi.alpha.devorch.com",
      "httpStatusCode": 200
    },
    "request": "subaccount/delete?params=vectorapi&subaccount&delete&18896&<some_token>&json",
    "response": {
      "subaccount": "18896"
    }
  }
}

+ **Other Optional Parameters**

    + Required Parameters : id
