| @@ -4,7 +4,7 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; | 
| 6 | 6 | |
| 7 | -class PUT extends AbstractRequest{ | |
| 7 | +class PUT extends AbstractRequest { | |
| 8 | 8 | |
| 9 | 9 | /** | 
| 10 | 10 | * @inheritdoc | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | * JSON Encode Body | 
| 33 | 33 | * @inheritdoc | 
| 34 | 34 | */ | 
| 35 | -    public function setBody($body) { | |
| 35 | +    public function setBody($body){ | |
| 36 | 36 | return parent::setBody(json_encode($body)); | 
| 37 | 37 | } | 
| 38 | 38 | |
| @@ -4,7 +4,7 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; | 
| 6 | 6 | |
| 7 | -class PUT extends AbstractRequest{ | |
| 7 | +class PUT extends AbstractRequest { | |
| 8 | 8 | |
| 9 | 9 | /** | 
| 10 | 10 | * @inheritdoc | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | * JSON Encode Body | 
| 33 | 33 | * @inheritdoc | 
| 34 | 34 | */ | 
| 35 | -    public function setBody($body) { | |
| 35 | +    public function setBody($body){ | |
| 36 | 36 | return parent::setBody(json_encode($body)); | 
| 37 | 37 | } | 
| 38 | 38 | |
| @@ -16,9 +16,9 @@ | ||
| 16 | 16 | * Overrides POST setBody, so that Body is not json encoded | 
| 17 | 17 | * @inheritdoc | 
| 18 | 18 | */ | 
| 19 | -    public function setBody($body) { | |
| 19 | +    public function setBody($body){ | |
| 20 | 20 | $this->body = $body; | 
| 21 | - $this->setOption(CURLOPT_POSTFIELDS,$this->body); | |
| 21 | + $this->setOption(CURLOPT_POSTFIELDS, $this->body); | |
| 22 | 22 | return $this; | 
| 23 | 23 | } | 
| 24 | 24 | |
| @@ -16,7 +16,7 @@ | ||
| 16 | 16 | * Overrides POST setBody, so that Body is not json encoded | 
| 17 | 17 | * @inheritdoc | 
| 18 | 18 | */ | 
| 19 | -    public function setBody($body) { | |
| 19 | +    public function setBody($body){ | |
| 20 | 20 | $this->body = $body; | 
| 21 | 21 | $this->setOption(CURLOPT_POSTFIELDS,$this->body); | 
| 22 | 22 | return $this; | 
| @@ -4,7 +4,7 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Interfaces\RequestInterface; | 
| 6 | 6 | |
| 7 | -abstract class AbstractRequest implements RequestInterface{ | |
| 7 | +abstract class AbstractRequest implements RequestInterface { | |
| 8 | 8 | |
| 9 | 9 | const STATUS_INIT = 'initialized'; | 
| 10 | 10 | const STATUS_SENT = 'sent'; | 
| @@ -81,31 +81,31 @@ discard block | ||
| 81 | 81 | $this->setURL($url); | 
| 82 | 82 | } | 
| 83 | 83 | $this->setType(); | 
| 84 | -        foreach(static::$_DEFAULT_OPTIONS as $option => $value){ | |
| 85 | - $this->setOption($option,$value); | |
| 84 | +        foreach (static::$_DEFAULT_OPTIONS as $option => $value){ | |
| 85 | + $this->setOption($option, $value); | |
| 86 | 86 | } | 
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | 89 | /** | 
| 90 | 90 | * @inheritdoc | 
| 91 | 91 | */ | 
| 92 | -    public function setURL($url) { | |
| 92 | +    public function setURL($url){ | |
| 93 | 93 | $this->url = $url; | 
| 94 | - $this->setOption(CURLOPT_URL,$this->url); | |
| 94 | + $this->setOption(CURLOPT_URL, $this->url); | |
| 95 | 95 | return $this; | 
| 96 | 96 | } | 
| 97 | 97 | |
| 98 | 98 | /** | 
| 99 | 99 | * @inheritdoc | 
| 100 | 100 | */ | 
| 101 | -    public function getURL() { | |
| 101 | +    public function getURL(){ | |
| 102 | 102 | return $this->url; | 
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | 105 | /** | 
| 106 | 106 | * @inheritdoc | 
| 107 | 107 | */ | 
| 108 | -    public function addHeader($name, $value) { | |
| 108 | +    public function addHeader($name, $value){ | |
| 109 | 109 | $token = $name.": ".$value; | 
| 110 | 110 | $this->headers[] = $token; | 
| 111 | 111 | return $this; | 
| @@ -114,9 +114,9 @@ discard block | ||
| 114 | 114 | /** | 
| 115 | 115 | * @inheritdoc | 
| 116 | 116 | */ | 
| 117 | -    public function setHeaders(array $array = array()) { | |
| 118 | -        if (count($array)>0) { | |
| 119 | -            foreach ($array as $key => $value) { | |
| 117 | +    public function setHeaders(array $array = array()){ | |
| 118 | +        if (count($array)>0){ | |
| 119 | +            foreach ($array as $key => $value){ | |
| 120 | 120 | $this->addHeader($key, $value); | 
| 121 | 121 | } | 
| 122 | 122 | } | 
| @@ -127,14 +127,14 @@ discard block | ||
| 127 | 127 | /** | 
| 128 | 128 | * @inheritdoc | 
| 129 | 129 | */ | 
| 130 | -    public function getHeaders() { | |
| 130 | +    public function getHeaders(){ | |
| 131 | 131 | return $this->headers; | 
| 132 | 132 | } | 
| 133 | 133 | |
| 134 | 134 | /** | 
| 135 | 135 | * @inheritdoc | 
| 136 | 136 | */ | 
| 137 | -    public function setBody($body) { | |
| 137 | +    public function setBody($body){ | |
| 138 | 138 | $this->body = $body; | 
| 139 | 139 | $this->setOption(CURLOPT_POSTFIELDS, $this->body); | 
| 140 | 140 | return $this; | 
| @@ -143,28 +143,28 @@ discard block | ||
| 143 | 143 | /** | 
| 144 | 144 | * @inheritdoc | 
| 145 | 145 | */ | 
| 146 | -    public function getBody() { | |
| 146 | +    public function getBody(){ | |
| 147 | 147 | return $this->body; | 
| 148 | 148 | } | 
| 149 | 149 | |
| 150 | 150 | /** | 
| 151 | 151 | * @inheritdoc | 
| 152 | 152 | */ | 
| 153 | -    public function getCurlObject() { | |
| 153 | +    public function getCurlObject(){ | |
| 154 | 154 | return $this->CurlRequest; | 
| 155 | 155 | } | 
| 156 | 156 | |
| 157 | 157 | /** | 
| 158 | 158 | * @inheritdoc | 
| 159 | 159 | */ | 
| 160 | -    public function setOption($option, $value) { | |
| 160 | +    public function setOption($option, $value){ | |
| 161 | 161 | curl_setopt($this->CurlRequest, $option, $value); | 
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | 164 | /** | 
| 165 | 165 | * @inheritdoc | 
| 166 | 166 | */ | 
| 167 | -    public function send() { | |
| 167 | +    public function send(){ | |
| 168 | 168 | $this->setHeaders(); | 
| 169 | 169 | $this->CurlResponse = curl_exec($this->CurlRequest); | 
| 170 | 170 | $this->status = self::STATUS_SENT; | 
| @@ -199,7 +199,7 @@ discard block | ||
| 199 | 199 | /** | 
| 200 | 200 | * @inheritdoc | 
| 201 | 201 | */ | 
| 202 | -    public function start() { | |
| 202 | +    public function start(){ | |
| 203 | 203 | $this->CurlRequest = curl_init(); | 
| 204 | 204 | $this->status = self::STATUS_INIT; | 
| 205 | 205 | return $this; | 
| @@ -218,7 +218,7 @@ discard block | ||
| 218 | 218 | /** | 
| 219 | 219 | * @inheritdoc | 
| 220 | 220 | */ | 
| 221 | -    public function getCurlStatus() { | |
| 221 | +    public function getCurlStatus(){ | |
| 222 | 222 | return $this->status; | 
| 223 | 223 | } | 
| 224 | 224 | } | 
| 225 | 225 | \ No newline at end of file | 
| @@ -4,7 +4,7 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Interfaces\RequestInterface; | 
| 6 | 6 | |
| 7 | -abstract class AbstractRequest implements RequestInterface{ | |
| 7 | +abstract class AbstractRequest implements RequestInterface { | |
| 8 | 8 | |
| 9 | 9 | const STATUS_INIT = 'initialized'; | 
| 10 | 10 | const STATUS_SENT = 'sent'; | 
| @@ -89,7 +89,7 @@ discard block | ||
| 89 | 89 | /** | 
| 90 | 90 | * @inheritdoc | 
| 91 | 91 | */ | 
| 92 | -    public function setURL($url) { | |
| 92 | +    public function setURL($url){ | |
| 93 | 93 | $this->url = $url; | 
| 94 | 94 | $this->setOption(CURLOPT_URL,$this->url); | 
| 95 | 95 | return $this; | 
| @@ -98,14 +98,14 @@ discard block | ||
| 98 | 98 | /** | 
| 99 | 99 | * @inheritdoc | 
| 100 | 100 | */ | 
| 101 | -    public function getURL() { | |
| 101 | +    public function getURL(){ | |
| 102 | 102 | return $this->url; | 
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | 105 | /** | 
| 106 | 106 | * @inheritdoc | 
| 107 | 107 | */ | 
| 108 | -    public function addHeader($name, $value) { | |
| 108 | +    public function addHeader($name, $value){ | |
| 109 | 109 | $token = $name.": ".$value; | 
| 110 | 110 | $this->headers[] = $token; | 
| 111 | 111 | return $this; | 
| @@ -114,9 +114,9 @@ discard block | ||
| 114 | 114 | /** | 
| 115 | 115 | * @inheritdoc | 
| 116 | 116 | */ | 
| 117 | -    public function setHeaders(array $array = array()) { | |
| 118 | -        if (count($array)>0) { | |
| 119 | -            foreach ($array as $key => $value) { | |
| 117 | +    public function setHeaders(array $array = array()){ | |
| 118 | +        if (count($array)>0){ | |
| 119 | +            foreach ($array as $key => $value){ | |
| 120 | 120 | $this->addHeader($key, $value); | 
| 121 | 121 | } | 
| 122 | 122 | } | 
| @@ -127,14 +127,14 @@ discard block | ||
| 127 | 127 | /** | 
| 128 | 128 | * @inheritdoc | 
| 129 | 129 | */ | 
| 130 | -    public function getHeaders() { | |
| 130 | +    public function getHeaders(){ | |
| 131 | 131 | return $this->headers; | 
| 132 | 132 | } | 
| 133 | 133 | |
| 134 | 134 | /** | 
| 135 | 135 | * @inheritdoc | 
| 136 | 136 | */ | 
| 137 | -    public function setBody($body) { | |
| 137 | +    public function setBody($body){ | |
| 138 | 138 | $this->body = $body; | 
| 139 | 139 | $this->setOption(CURLOPT_POSTFIELDS, $this->body); | 
| 140 | 140 | return $this; | 
| @@ -143,28 +143,28 @@ discard block | ||
| 143 | 143 | /** | 
| 144 | 144 | * @inheritdoc | 
| 145 | 145 | */ | 
| 146 | -    public function getBody() { | |
| 146 | +    public function getBody(){ | |
| 147 | 147 | return $this->body; | 
| 148 | 148 | } | 
| 149 | 149 | |
| 150 | 150 | /** | 
| 151 | 151 | * @inheritdoc | 
| 152 | 152 | */ | 
| 153 | -    public function getCurlObject() { | |
| 153 | +    public function getCurlObject(){ | |
| 154 | 154 | return $this->CurlRequest; | 
| 155 | 155 | } | 
| 156 | 156 | |
| 157 | 157 | /** | 
| 158 | 158 | * @inheritdoc | 
| 159 | 159 | */ | 
| 160 | -    public function setOption($option, $value) { | |
| 160 | +    public function setOption($option, $value){ | |
| 161 | 161 | curl_setopt($this->CurlRequest, $option, $value); | 
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | 164 | /** | 
| 165 | 165 | * @inheritdoc | 
| 166 | 166 | */ | 
| 167 | -    public function send() { | |
| 167 | +    public function send(){ | |
| 168 | 168 | $this->setHeaders(); | 
| 169 | 169 | $this->CurlResponse = curl_exec($this->CurlRequest); | 
| 170 | 170 | $this->status = self::STATUS_SENT; | 
| @@ -199,7 +199,7 @@ discard block | ||
| 199 | 199 | /** | 
| 200 | 200 | * @inheritdoc | 
| 201 | 201 | */ | 
| 202 | -    public function start() { | |
| 202 | +    public function start(){ | |
| 203 | 203 | $this->CurlRequest = curl_init(); | 
| 204 | 204 | $this->status = self::STATUS_INIT; | 
| 205 | 205 | return $this; | 
| @@ -218,7 +218,7 @@ discard block | ||
| 218 | 218 | /** | 
| 219 | 219 | * @inheritdoc | 
| 220 | 220 | */ | 
| 221 | -    public function getCurlStatus() { | |
| 221 | +    public function getCurlStatus(){ | |
| 222 | 222 | return $this->status; | 
| 223 | 223 | } | 
| 224 | 224 | } | 
| 225 | 225 | \ No newline at end of file | 
| @@ -4,7 +4,7 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; | 
| 6 | 6 | |
| 7 | -class DELETE extends AbstractRequest{ | |
| 7 | +class DELETE extends AbstractRequest { | |
| 8 | 8 | |
| 9 | 9 | /** | 
| 10 | 10 | * @inheritdoc | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | * JSON Encode Body | 
| 33 | 33 | * @inheritdoc | 
| 34 | 34 | */ | 
| 35 | -    public function setBody($body) { | |
| 35 | +    public function setBody($body){ | |
| 36 | 36 | return parent::setBody(json_encode($body)); | 
| 37 | 37 | } | 
| 38 | 38 | |
| @@ -4,7 +4,7 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; | 
| 6 | 6 | |
| 7 | -class DELETE extends AbstractRequest{ | |
| 7 | +class DELETE extends AbstractRequest { | |
| 8 | 8 | |
| 9 | 9 | /** | 
| 10 | 10 | * @inheritdoc | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | * JSON Encode Body | 
| 33 | 33 | * @inheritdoc | 
| 34 | 34 | */ | 
| 35 | -    public function setBody($body) { | |
| 35 | +    public function setBody($body){ | |
| 36 | 36 | return parent::setBody(json_encode($body)); | 
| 37 | 37 | } | 
| 38 | 38 | |
| @@ -22,7 +22,7 @@ | ||
| 22 | 22 | * @param mixed $data | 
| 23 | 23 | * @return array|mixed | 
| 24 | 24 | */ | 
| 25 | -    protected function configureData($data) { | |
| 25 | +    protected function configureData($data){ | |
| 26 | 26 |          if (is_array($data)){ | 
| 27 | 27 | $data['grant_type'] = 'password'; | 
| 28 | 28 |          }elseif (is_object($data)){ | 
| @@ -22,10 +22,10 @@ | ||
| 22 | 22 | * @param mixed $data | 
| 23 | 23 | * @return array|mixed | 
| 24 | 24 | */ | 
| 25 | -    protected function configureData($data) { | |
| 25 | +    protected function configureData($data){ | |
| 26 | 26 |          if (is_array($data)){ | 
| 27 | 27 | $data['grant_type'] = 'password'; | 
| 28 | -        }elseif (is_object($data)){ | |
| 28 | +        } elseif (is_object($data)){ | |
| 29 | 29 | $data->grant_type = 'password'; | 
| 30 | 30 | } | 
| 31 | 31 | return $data; | 
| @@ -19,7 +19,7 @@ | ||
| 19 | 19 | * @param mixed $data | 
| 20 | 20 | * @return array|mixed | 
| 21 | 21 | */ | 
| 22 | -    protected function configureData($data) { | |
| 22 | +    protected function configureData($data){ | |
| 23 | 23 |          if (is_array($data)){ | 
| 24 | 24 | $data['grant_type'] = 'refresh_token'; | 
| 25 | 25 |          }elseif (is_object($data)){ | 
| @@ -19,10 +19,10 @@ | ||
| 19 | 19 | * @param mixed $data | 
| 20 | 20 | * @return array|mixed | 
| 21 | 21 | */ | 
| 22 | -    protected function configureData($data) { | |
| 22 | +    protected function configureData($data){ | |
| 23 | 23 |          if (is_array($data)){ | 
| 24 | 24 | $data['grant_type'] = 'refresh_token'; | 
| 25 | -        }elseif (is_object($data)){ | |
| 25 | +        } elseif (is_object($data)){ | |
| 26 | 26 | $data->grant_type = 'refresh_token'; | 
| 27 | 27 | } | 
| 28 | 28 | return $data; | 
| @@ -32,23 +32,23 @@ discard block | ||
| 32 | 32 | $fileField => $data | 
| 33 | 33 | ); | 
| 34 | 34 | } | 
| 35 | -        if (is_array($data)) { | |
| 36 | -            if (isset($fileField)) { | |
| 35 | +        if (is_array($data)){ | |
| 36 | +            if (isset($fileField)){ | |
| 37 | 37 | $data[$fileField] = $this->setFileFieldValue($data[$fileField]); | 
| 38 | -            }else { | |
| 39 | -                foreach ($data as $key => $value) { | |
| 40 | -                    if (strtolower($key) !== 'oauth_token' || strtolower($key) !== 'delete_if_fails' || strtolower($key) !== 'format') { | |
| 38 | +            }else{ | |
| 39 | +                foreach ($data as $key => $value){ | |
| 40 | +                    if (strtolower($key)!=='oauth_token' || strtolower($key)!=='delete_if_fails' || strtolower($key)!=='format'){ | |
| 41 | 41 | $data[$key] = $this->setFileFieldValue($value); | 
| 42 | 42 | } | 
| 43 | 43 | } | 
| 44 | 44 | } | 
| 45 | 45 | $data['oauth_token'] = $this->accessToken; | 
| 46 | - $data['delete_if_fails'] = (isset($data['delete_if_fails']) ? $data['delete_if_fails'] : TRUE); | |
| 46 | + $data['delete_if_fails'] = (isset($data['delete_if_fails'])?$data['delete_if_fails']:TRUE); | |
| 47 | 47 | $data['format'] = 'sugar-html-json'; | 
| 48 | 48 |          }elseif (is_object($data) && isset($fileField)){ | 
| 49 | 49 | $data->$fileField = $this->setFileFieldValue($data->$fileField); | 
| 50 | 50 | $data->oauth_token = $this->accessToken; | 
| 51 | - $data->delete_if_fails = (isset($data->delete_if_fails) ? $data->delete_if_fails : TRUE); | |
| 51 | + $data->delete_if_fails = (isset($data->delete_if_fails)?$data->delete_if_fails:TRUE); | |
| 52 | 52 | $data->format = 'sugar-html-json'; | 
| 53 | 53 | } | 
| 54 | 54 | return $data; | 
| @@ -60,8 +60,8 @@ discard block | ||
| 60 | 60 | * @return string | 
| 61 | 61 | */ | 
| 62 | 62 |      protected function setFileFieldValue($value){ | 
| 63 | -        if (strpos($value, '@') === FALSE) { | |
| 64 | - $value = '@' . $value; | |
| 63 | +        if (strpos($value, '@')===FALSE){ | |
| 64 | + $value = '@'.$value; | |
| 65 | 65 | } | 
| 66 | 66 | return $value; | 
| 67 | 67 | } | 
| @@ -32,12 +32,12 @@ discard block | ||
| 32 | 32 | $fileField => $data | 
| 33 | 33 | ); | 
| 34 | 34 | } | 
| 35 | -        if (is_array($data)) { | |
| 36 | -            if (isset($fileField)) { | |
| 35 | +        if (is_array($data)){ | |
| 36 | +            if (isset($fileField)){ | |
| 37 | 37 | $data[$fileField] = $this->setFileFieldValue($data[$fileField]); | 
| 38 | -            }else { | |
| 39 | -                foreach ($data as $key => $value) { | |
| 40 | -                    if (strtolower($key) !== 'oauth_token' || strtolower($key) !== 'delete_if_fails' || strtolower($key) !== 'format') { | |
| 38 | +            } else{ | |
| 39 | +                foreach ($data as $key => $value){ | |
| 40 | +                    if (strtolower($key) !== 'oauth_token' || strtolower($key) !== 'delete_if_fails' || strtolower($key) !== 'format'){ | |
| 41 | 41 | $data[$key] = $this->setFileFieldValue($value); | 
| 42 | 42 | } | 
| 43 | 43 | } | 
| @@ -45,7 +45,7 @@ discard block | ||
| 45 | 45 | $data['oauth_token'] = $this->accessToken; | 
| 46 | 46 | $data['delete_if_fails'] = (isset($data['delete_if_fails']) ? $data['delete_if_fails'] : TRUE); | 
| 47 | 47 | $data['format'] = 'sugar-html-json'; | 
| 48 | -        }elseif (is_object($data) && isset($fileField)){ | |
| 48 | +        } elseif (is_object($data) && isset($fileField)){ | |
| 49 | 49 | $data->$fileField = $this->setFileFieldValue($data->$fileField); | 
| 50 | 50 | $data->oauth_token = $this->accessToken; | 
| 51 | 51 | $data->delete_if_fails = (isset($data->delete_if_fails) ? $data->delete_if_fails : TRUE); | 
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | * @return string | 
| 61 | 61 | */ | 
| 62 | 62 |      protected function setFileFieldValue($value){ | 
| 63 | -        if (strpos($value, '@') === FALSE) { | |
| 63 | +        if (strpos($value, '@') === FALSE){ | |
| 64 | 64 | $value = '@' . $value; | 
| 65 | 65 | } | 
| 66 | 66 | return $value; | 
| @@ -1,16 +1,16 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -require_once __DIR__ . '/../vendor/autoload.php'; | |
| 3 | +require_once __DIR__.'/../vendor/autoload.php'; | |
| 4 | 4 | |
| 5 | 5 |  try{ | 
| 6 | -    $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/',array('username' => 'admin','password'=>'asdf')); | |
| 6 | +    $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/', array('username' => 'admin', 'password'=>'asdf')); | |
| 7 | 7 | $SugarAPI->login(); | 
| 8 | 8 |      $EP = $SugarAPI->createRecord('Notes')->data(array('name' => 'Test Note'))->execute(); | 
| 9 | 9 | $response = $EP->getResponse(); | 
| 10 | 10 |      if ($response->getStatus()=='200'){ | 
| 11 | 11 | $record = $response->getBody(); | 
| 12 | 12 | |
| 13 | -        $upload = $SugarAPI->attachFile('Notes',$record->id,'filename')->data(__DIR__.'/testfile.txt;filename=testfile.txt')->execute(); | |
| 13 | +        $upload = $SugarAPI->attachFile('Notes', $record->id, 'filename')->data(__DIR__.'/testfile.txt;filename=testfile.txt')->execute(); | |
| 14 | 14 | $response = $upload->getResponse(); | 
| 15 | 15 |          if ($response->getStatus()=='200'){ | 
| 16 | 16 | $record = $response->getBody(); | 
| @@ -27,6 +27,6 @@ discard block | ||
| 27 | 27 | print_r($response->getBody()); | 
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | -}catch(\SugarAPI\SDK\Exception\SDKException $ex){ | |
| 30 | +}catch (\SugarAPI\SDK\Exception\SDKException $ex){ | |
| 31 | 31 | print $ex->getMessage(); | 
| 32 | 32 | } | 
| 33 | 33 | \ No newline at end of file | 
| @@ -1,22 +1,22 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | 3 | |
| 4 | -require_once __DIR__ . '/../vendor/autoload.php'; | |
| 4 | +require_once __DIR__.'/../vendor/autoload.php'; | |
| 5 | 5 | |
| 6 | 6 |  try{ | 
| 7 | -    $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7700/',array('username' => 'admin','password'=>'asdf')); | |
| 7 | +    $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7700/', array('username' => 'admin', 'password'=>'asdf')); | |
| 8 | 8 | $SugarAPI->login(); | 
| 9 | 9 |      $EP = $SugarAPI->filterRecords('Accounts'); | 
| 10 | 10 | $response = $EP->execute()->getResponse(); | 
| 11 | 11 |      if ($response->getStatus()=='200'){ | 
| 12 | 12 | $recordList = $response->getBody(); | 
| 13 | - $max=count($recordList->records); | |
| 13 | + $max = count($recordList->records); | |
| 14 | 14 | echo "Found $max records from Filter Records request. <br>"; | 
| 15 | - $number = rand(0,$max); | |
| 15 | + $number = rand(0, $max); | |
| 16 | 16 | $randomRecord = $recordList->records[$number]; | 
| 17 | 17 | echo "Choose random record #$number, with ID: ".$randomRecord->id." <br>"; | 
| 18 | 18 | |
| 19 | -        $getRecord = $SugarAPI->getRecord('Accounts',$randomRecord->id)->data(array( | |
| 19 | +        $getRecord = $SugarAPI->getRecord('Accounts', $randomRecord->id)->data(array( | |
| 20 | 20 | 'fields' => 'name' | 
| 21 | 21 | ))->execute(); | 
| 22 | 22 | $response = $getRecord->getResponse(); | 
| @@ -24,14 +24,14 @@ discard block | ||
| 24 | 24 | echo "Retrieved Record <br>"; | 
| 25 | 25 | $randomRecord = $getRecord->getResponse()->getBody(); | 
| 26 | 26 | $randomRecord->name = 'Updated Record Name'; | 
| 27 | -            $updateRecord = $SugarAPI->updateRecord('Accounts',$randomRecord->id)->data($randomRecord)->execute(); | |
| 27 | +            $updateRecord = $SugarAPI->updateRecord('Accounts', $randomRecord->id)->data($randomRecord)->execute(); | |
| 28 | 28 | $response = $updateRecord->getResponse(); | 
| 29 | 29 |              if ($response->getStatus()=='200'){ | 
| 30 | 30 | $randomRecord = $updateRecord->getResponse()->getBody(); | 
| 31 | 31 | echo "Updated Record <br>"; | 
| 32 | 32 | print_r($randomRecord); | 
| 33 | 33 | |
| 34 | -                $deleteRecord = $SugarAPI->deleteRecord('Accounts',$randomRecord->id)->execute(); | |
| 34 | +                $deleteRecord = $SugarAPI->deleteRecord('Accounts', $randomRecord->id)->execute(); | |
| 35 | 35 | $response = $deleteRecord->getResponse(); | 
| 36 | 36 |                  if ($response->getStatus()=='200'){ | 
| 37 | 37 | $response = $deleteRecord->getResponse()->getBody(); | 
| @@ -57,11 +57,11 @@ discard block | ||
| 57 | 57 | echo "Response: ".$response->getStatus(); | 
| 58 | 58 | print_r($response->getBody()); | 
| 59 | 59 | } | 
| 60 | -}catch(\SugarAPI\SDK\Exception\AuthenticationException $ex){ | |
| 60 | +}catch (\SugarAPI\SDK\Exception\AuthenticationException $ex){ | |
| 61 | 61 | echo "Auth Options:<pre>"; | 
| 62 | 62 | print_r($SugarAPI->getAuthOptions()); | 
| 63 | 63 | echo "</pre> Error Message: "; | 
| 64 | 64 | print $ex->getMessage(); | 
| 65 | -}catch(\SugarAPI\SDK\Exception\SDKException $ex){ | |
| 65 | +}catch (\SugarAPI\SDK\Exception\SDKException $ex){ | |
| 66 | 66 | echo $ex->__toString(); | 
| 67 | 67 | } |