Force the disposal of a project

Description

Force the status of a project to be "disposed", so that voice actors can't submit reads for it any longer. If no reads have been received the rewardAmount of the project will be credited back to your account.

Response example

{
  "projects":[
    {
      "id":"1",
      "user":"42",
      "status":"disposed",
      "fulfilmentType":"speedy",
      "title":"My Test Project",
      "language":"eng-us",
      "genderAndAge":"youngAdultMale",
      "script":{
        "part001":"This is my script 1."
      },
      "price":"0.150000002235174",
      "currency":"USD",
      "remarks":"Special instructions",
      "lifetime":"1",
      "assignmentDuration":"609",
      "test":0,
      "created":1315692607,
      "units":"4",
      "genderAndAgeName":"Male | Young adult (20-39)",
      "languageName":"English - North America",
      "auditionScript":false,
      "reads":[
        {
          "status":"futureRead",
          "urls":{
            "part001":{
              "default":"https:\/\/voicebunny.com\/reads\/files\/1\/default\/part001",
              "original":"https:\/\/voicebunny.com\/reads\/files\/1\/original\/part001"
            }
          }
        }
      ],
      "auditions":false,
      "talendID":null,
      "syncedRecording":0,
      "excludePrevious":false,
      "extended":0,
      "extendedRequestedTime":false,
      "extensionLifetime":false,
      "prioritizeFavoriteListId":false
    }
  ],
  "timestamp":1571315957
}
<?xml version="1.0" encoding="UTF-8"?>
<projects>
  <project>
    <id>1</id>
    <user>42</user>
    <status>disposed</status>
    <fulfilmentType>speedy</fulfilmentType>
    <title>My Test Project</title>
    <language>eng-us</language>
    <genderAndAge>youngAdultMale</genderAndAge>
    <script>
      <part001>This is my script 1.</part001>
    </script>
    <price>0.150000002235174</price>
    <currency>USD</currency>
    <remarks>Special instructions</remarks>
    <lifetime>1</lifetime>
    <assignmentDuration>609</assignmentDuration>
    <test>0</test>
    <created>1315692607</created>
    <units>4</units>
    <genderAndAgeName>Male | Young adult (20-39)</genderAndAgeName>
    <languageName>English - North America</languageName>
    <auditionScript>0</auditionScript>
    <reads>
      <status>futureRead</status>
      <urls>
        <part001>
          <default>https://voicebunny.com/reads/files/1/default/part001</default>
          <original>https://voicebunny.com/reads/files/1/original/part001</original>
        </part001>
      </urls>
    </reads>
    <auditions>0</auditions>
    <talendID/>
    <syncedRecording>0</syncedRecording>
    <excludePrevious>0</excludePrevious>
    <extended>0</extended>
    <extendedRequestedTime>0</extendedRequestedTime>
    <extensionLifetime>0</extensionLifetime>
    <prioritizeFavoriteListId>0</prioritizeFavoriteListId>
  </project>
  <timestamp>1571315957</timestamp>
</projects>

Errors

  • 5013: You are not authorized to modify this project. Only the owner can modify it.
  • 5014: This project is already in status "disposed".
  • 5015: The project cannot be disposed as one talent already accepted it and is working on it.
  • 5016: Given that there is a deliverable in status "reviewable", you must approve it or reject it before disposing this project.
  • 5017: The project does not exists.

Code example

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.2' )

import groovyx.net.http.*
import groovy.json.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*

http = new HTTPBuilder('https://api.voicebunny.com')
http.handler.success = {response, json -> return json}
http.handler.failure = {response, json -> throw new RuntimeException(json.error.code + ' ' + json.error.message)}
def voicebunnyUser = 'xxXXxx'
def voicebunnyToken = 'xxxxXXXXxxxxXXXX'
def projectId = 'xx'
http.auth.basic voicebunnyUser, voicebunnyToken
def disposedProject = http.post(path: 'projects/forceDispose/' + projectId, requestContentType: URLENC)
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.Map.Entry;
import org.apache.commons.codec.binary.Base64;

public class Voicebunny {

    private String user = "xxXXxx";

    private String token = "xxxxXXXXxxxxXXXX";

    private String encodedAuthorization = "";

    private String host = "https://api.voicebunny.com";

    public Voicebunny() {
        String userpassword = user + ":" + token;
        encodedAuthorization = Base64.encodeBase64String(userpassword.getBytes());
    }

    public static void main(String[] args) throws IOException {
        Voicebunny vb = new Voicebunny();
        System.out.println(vb.forceDisposeProject("projectId"));
    }

    private String forceDisposeProject(String id) throws UnsupportedEncodingException, MalformedURLException, ProtocolException, IOException {
        Map<String, String> params = new HashMap<String, String>();

        return post("projects/forceDispose/" + id, params);
    }

    private String post(String resource, Map<String, String> params) throws UnsupportedEncodingException, MalformedURLException, IOException, ProtocolException {
        String data = "";
        for (Entry<String, String> entry : params.entrySet()) {
            if (!data.isEmpty()) {
                data += "&";
            }
            data += (URLEncoder.encode(entry.getKey(), "UTF-8") + "=" + URLEncoder.encode(entry.getValue(), "UTF-8"));
        }

        URL url = new URL(host + "/" + resource);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Authorization", "Basic " + encodedAuthorization);
        connection.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(connection.getOutputStream());
        wr.write(data);
        wr.flush();
        InputStream in = connection.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        StringBuffer sb = new StringBuffer();
        String line = "";
        while ((line = reader.readLine()) != null) {
            sb.append(line);
        }
        wr.close();
        reader.close();
        return sb.toString();
    }

}
<?php
$voicebunnyUser = 'xxXXxx';
$voicebunnyToken = 'xxxxXXXXxxxxXXXX';
$projectId = 'x';
$url_api = 'https://api.voicebunny.com/projects/forceDispose/' . $projectId;
$postVars = array();
$vars = http_build_query($postVars);
$opts = array(
	CURLOPT_URL => $url_api,
	CURLOPT_RETURNTRANSFER => TRUE,
	CURLOPT_INFILESIZE => -1,
	CURLOPT_TIMEOUT => 60,
	CURLOPT_SSL_VERIFYPEER => false,
	CURLOPT_POST => TRUE,
	CURLOPT_POSTFIELDS => $vars,
	CURLOPT_USERPWD => $voicebunnyUser . ':' . $voicebunnyToken,
);
$curl = curl_init();
curl_setopt_array($curl, $opts);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
print_r($response);
?>
import requests
import simplejson
from requests.auth import HTTPBasicAuth

url = 'https://api.voicebunny.com'
api_id = 'XX'
api_key = "xxxxXXXXxxxxXXXX"
project_id = 'XX'
req = requests.get(url+'/projects/forceDispose/'+project_id,
    auth=HTTPBasicAuth(api_id, api_key),verify=False)
data = simplejson.loads(req.text)
response = data['projects']
require 'faraday'
require 'faraday_middleware'

@conn = nil
@api_id = "XX"
@api_key = "xxxxXXXXxxxxXXXX"
project_id = "X"
resp = nil

@conn = Faraday.new(:url =>("https://"+ @api_id+":"+@api_key +"@api.voicebunny.com"),:ssl => {:verify => false}) do |builder|
	builder.use Faraday::Request::Multipart
	builder.use Faraday::Request::UrlEncoded
	builder.use Faraday::Response::ParseJson
	builder.use Faraday::Adapter::NetHttp		  
end

resp = @conn.get '/projects/forceDispose/'+project_id+'.json'
resp.body