-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclass-gf-connectwise-2018v6.php
76 lines (63 loc) · 2.27 KB
/
class-gf-connectwise-2018v6.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
require_once WP_PLUGIN_DIR . '/connectwise-forms-integration/class-gf-connectwise.php';
GFForms::include_feed_addon_framework();
class GFConnectWise2018v6 extends GFConnectWise {
private static $_instance = null;
public static function get_instance() {
if ( null == self::$_instance ) {
self::$_instance = new self;
}
return self::$_instance;
}
public function get_team_members() {
$this->log_debug( __METHOD__ . '(): start getting team members from ConnectWise' );
$team_members_list = array();
$get_team_members_url = 'system/members?pageSize=200';
$cw_team_members = $this->send_request( $get_team_members_url, 'GET', NULL );
$cw_team_members = json_decode( $cw_team_members['body'] );
foreach ( $cw_team_members as $each_member ) {
$member = array(
'label' => esc_html__( $each_member->firstName . ' ' . $each_member->lastName, 'gravityformsconnectwise' ),
'value' => $each_member->identifier
);
array_push( $team_members_list, $member );
}
$this->log_debug( __METHOD__ . '(): finish getting team members from ConnectWise' );
return $team_members_list;
}
public function prepare_company_data( $data_to_prepare ) {
$company_data = array(
'id' => 0,
'identifier' => $data_to_prepare['identifier'],
'name' => $data_to_prepare['company'],
'addressLine1' => $data_to_prepare['address_line1'],
'addressLine2' => $data_to_prepare['address_line2'],
'city' => $data_to_prepare['city'],
'state' => $data_to_prepare['state'],
'zip' => $data_to_prepare['zip'],
'phoneNumber' => $data_to_prepare['phone_number'],
'faxNumber' => $data_to_prepare['fax_number'],
'website' => $data_to_prepare['web_site'],
'typeIds' => array(
$data_to_prepare['company_type'],
),
'status' => array(
'id' => $data_to_prepare['company_status'],
)
);
return $company_data;
}
public function prepare_contact_data( $data_to_prepare ) {
$contact_data = array(
'firstName' => $data_to_prepare['first_name'],
'lastName' => $data_to_prepare['last_name'],
'company' => array(
'identifier' => $data_to_prepare['identifier'],
),
'typeIds' => array(
$data_to_prepare['contact_type'],
),
);
return $contact_data;
}
}