Code Monkey home page Code Monkey logo

php-api's Introduction

#PHP API v2.0.0 PHP Client to access Agile functionality

#Intro

  1. Fill in your AGILE_DOMAIN, AGILE_USER_EMAIL, AGILE_REST_API_KEY in curlwrap_v2.php.

  2. Copy and paste the source / include the curlwrap_v2.php in your php code.

  3. You need to provide 3 paramaters to the curl_wrap function. They are $entity, $data, $method.

  • $entity should be one of "contacts/{id}", "contacts", "opportunity/{id}", "opportunity", "notes", "contacts/{contact_id}/notes", "contacts/{contact_id}/notes/{note_id}", "tasks/{id}", "tasks", "events", "events/{id}", "milestone/pipelines", "milestone/pipelines/{id}" depending on requirement.

  • $data must be stringified JSON.

$data = array(
  "properties"=>array(
    array(
      "name"=>"first_name",
      "value"=>"phprest",
      "type"=>"SYSTEM"
    ),
    array(
      "name"=>"last_name",
      "value"=>"contact",
      "type"=>"SYSTEM"
    ),
    array(
      "name"=>"email",
      "value"=>"[email protected]",
      "type"=>"SYSTEM"
    )
  )
);

$data = json_encode($data);
  • $method can be set to

    POST to create an entity (contact, deal, task, event).
    
    GET to fetch an entity.
    
    PUT to update entity.
    
    DELETE to remove an entity.
    

#Usage

1. Contact

1.1 To create a contact

$contact_json = array(
  "properties"=>array(
    array(
      "name"=>"first_name",
      "value"=>"phprest",
      "type"=>"SYSTEM"
    ),
    array(
      "name"=>"last_name",
      "value"=>"contact",
      "type"=>"SYSTEM"
    ),
    array(
      "name"=>"email",
      "value"=>"[email protected]",
      "type"=>"SYSTEM"
    )
  )
);

$contact_json = json_encode($contact_json);
curl_wrap("contacts", $contact_json, "POST");

1.2 To fetch contact data

curl_wrap("contacts/5722721933590528", null, "GET");

1.3 To delete a contact

curl_wrap("contacts/5722721933590528", null, "DELETE");

1.4 To update a contact

$contact_json = array(
  "id"=>5722721933590528,
  "properties"=>array(
    array(
      "name"=>"first_name",
      "value"=>"php",
      "type"=>"SYSTEM"
    ),
    array(
      "name"=>"last_name",
      "value"=>"contact",
      "type"=>"SYSTEM"
    ),
    array(
      "name"=>"email",
      "value"=>"[email protected]",
      "type"=>"SYSTEM"
    )
  )
);

$contact_json = json_encode($contact_json);
curl_wrap("contacts", $contact_json, "PUT");

2. Company

2.1 To create a company

$company_json = array(
"type"=>"COMPANY",
"properties"=>array(
    array(
      "name"=>"name",
      "value"=>"test company",
      "type"=>"SYSTEM"
    ),
    array(
      "name"=>"url",
      "value"=>"https://www.testcompany.org",
      "type"=>"SYSTEM"
    )
  )
);

$company_json = json_encode($company_json);
curl_wrap("contacts", $company_json, "POST");

2.2 To get a company

curl_wrap("contacts/5695414665740288", null, "GET");

2.3 To delete a company

curl_wrap("contacts/5695414665740288", null, "DELETE")

2.4 To update a company

$company_json = array(
  "id"=>5695414665740288,
  "type"=>"COMPANY",
  "properties"=>array(
  array(
    "name"=>"name",
    "value"=>"test company",
    "type"=>"SYSTEM"
  ),
  array(
    "name"=>"url",
    "value"=>"https://www.test-company.org",
    "type"=>"SYSTEM"
    )
  )
);

$company_json = json_encode($company_json);
curl_wrap("contacts", $company_json, "PUT");

3. Deal (Opportunity)

3.1 To create a deal

$opportunity_json = array(
  "name"=>"test deal",
  "description"=>"this is a test deal",
  "expected_value"=>1000,
  "milestone"=>"Open",
  "probability"=>50,
  "close_date"=>1414317504,
  "contact_ids"=>array(5722721933590528)
);

$opportunity_json = json_encode($opportunity_json);
curl_wrap("opportunity", $opportunity_json, "POST");

3.2 To get a deal

curl_wrap("opportunity/5739083074633728", null, "GET");

3.3 To delete a deal

curl_wrap("opportunity/5739083074633728", null, "DELETE");

3.4 To update deal

$opportunity_json = array(
  "id"=>5739083074633728,
  "name"=>"test",
  "description"=>"this is a test deal",
  "expected_value"=>1000,
  "milestone"=>"Open",
  "probability"=>50,
  "close_date"=>1414317504,
  "contact_ids"=>array(5722721933590528)
);

$opportunity_json = json_encode($opportunity_json);
curl_wrap("opportunity", $opportunity_json, "PUT");

4. Note

4.1 To create a note

$note_json = array(
  "subject"=>"test note",
  "description"=>"this is a test note",
  "contact_ids"=>array(5722721933590528),
  "owner_id"=>3103059
);

$note_json = json_encode($note_json);
curl_wrap("notes", $note_json, POST);

4.2 To get all notes related to specific contact

curl_wrap("contacts/5722721933590528/notes", null, "GET");

4.3 To update a note

$note_json = array(
  "id"=>1414322285,
  "subject"=>"note",
  "description"=>"this is a test note",
  "contact_ids"=>array(5722721933590528),
  "owner_id"=>3103059
);

$note_json = json_encode($note_json);
curl_wrap("notes", $note_json, "PUT");

5. Task

5.1 To create a task

$task_json = array(
  "type"=>"MILESTONE",
  "priority_type"=>"HIGH",
  "due"=>1414671165,
  "contacts"=>array(5722721933590528),
  "subject"=>"this is a test task",
  "status"=>"YET_TO_START",
  "owner_id"=>3103059
);

$task_json = json_encode($task_json);
curl_wrap("tasks", $task_json, "POST");

5.2 To get a task

curl_wrap("tasks/5752207420948480", null, "GET");

5.3 To delete a task

curl_wrap("tasks/5752207420948480", null, "DELETE");

5.4 To update a task

$task_json = array(
  "id"=>5752207420948480,
  "type"=>"MILESTONE",
  "priority_type"=>"LOW",
  "due"=>1414671165,
  "contacts"=>array(5722721933590528),
  "subject"=>"this is a test task",
  "status"=>"YET_TO_START",
  "owner_id"=>3103059
);

$task_json = json_encode($task_json);
curl_wrap("tasks", $task_json, "PUT");

6. Event

6.1 To create a event

$event_json = array(
  "start"=>1414155679,
  "end"=>1414328479,
  "title"=>"this is a test event",
  "contacts"=>array(5722721933590528),
  "allDay"=>true
);

$event_json = json_encode($event_json);
curl_wrap("events", $event_json, "POST");

6.2 To delete a event

curl_wrap("events/5703789046661120", null, "DELETE");

6.3 To update a event

$event_json = array(
  "id"=>5703789046661120,
  "start"=>1414155679,
  "end"=>1414328479,
  "title"=>"this is a test event",
  "contacts"=>array(5722721933590528),
  "allDay"=>false
);

$event_json = json_encode($event_json);
curl_wrap("events", $event_json, "PUT");

7. Deal Tracks and Milestones

7.1 To create a track

$milestone_json = array(
  "name"=>"new",
  "milestones"=>"one, two, three"
);

$milestone_json = json_encode($milestone_json);
curl_wrap("milestone/pipelines", $milestone_json, "POST")

7.2 To get all tracks

curl_wrap("milestone/pipelines", null, "GET");

7.3 To update track

$milestone_json = array(
  "id"=>5659711005261824,
  "name"=>"latest",
  "milestones"=>"one, two, three, four"
);

$milestone_json = json_encode($milestone_json);
curl_wrap("milestone/pipelines", $milestone_json, "PUT");

7.4 To delete a track

curl_wrap("milestone/pipelines/5659711005261824", null, "DELETE");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.