create a webhook

@param mixed  $params
@param string $apiKey
@return mixed
483980
public static function create($params = null, $apiKey = null)
    {
        if (!isset($params['webhook']) || !is_array($params['webhook'])) {
            $clone = $params;
            unset($params);
            $params['webhook'] = $clone;
        }

        return self::_create(get_class(), $params, $apiKey);
    }
16912
public function send($apiMethod, array $params = [], $requestMethod = "POST")
    {
        $requestMethod = strtoupper($requestMethod);

        $httpRequest        = $this->_createHttpRequest($apiMethod, $params, $requestMethod);
        $httpResponse       = $httpRequest->send();

        $apiResponse = new ApiResponse([
            'api'                   => $this,
            'httpClientRequest'     => $httpRequest,
            'httpClientResponse'    => $httpResponse,
            'apiMethod'             => $apiMethod,
        ]);

        return $apiResponse;
    }
751063
public function _createHttpRequest($apiMethod, array $params = [], $requestMethod = "POST")
    {
        $apiUrl = $this->baseUrl . $apiMethod;
        $client     = new Client();

        if ($requestMethod == "POST")
        {
            $client->requestConfig = ['format' => Client::FORMAT_JSON];
        }

        $request    = $client
            ->createRequest()
            ->setUrl($apiUrl)
            ->setMethod($requestMethod)
            ->addHeaders(['Authorization' => "Token " . $this->authorization_token])
            ->addHeaders(['Accept' => 'application/json'])
            ->setData($params)
            ->setOptions([
                'timeout' => $this->timeout
            ])
        ;

        if ($requestMethod == "POST")
        {
            return $request->addHeaders(['Content-type' => 'application/json']);

        } else if ($requestMethod == "GET")
        {
            return $request;
        }

        throw new \InvalidArgumentException("Method {$requestMethod} not allow");
    }
831112
public function triggerHook()
    {
        $hookUrl = $this->getLink('#hook');
        $options = [];

        // The API needs us to send an empty JSON object.
        $options['json'] = new \stdClass();

        // Switch off authentication for this request (none is required).
        $options['auth'] = null;

        $this->sendRequest($hookUrl, 'post', $options);
    }
970915
public static function key(string $key, array $params = []): string
    {
        $key = md5(serialize($key));
        if (count($params) > 0) {
            $key .= '-' . md5(serialize($params));
        }
        return $key;
    }
1284468
public static function build($apiKey)
    {
        self::$apiKey          = $apiKey;
        static::$cachedFactory = new ServiceBuilderLoader();

        return parent::factory(__DIR__.'/Resources/clients.json');
    }
1109646
public function login($apiUser = null, $apiKey = null)
    {
        if (null === $apiUser) {
            $apiUser = $this->apiUser;
        }

        if (null === $apiKey) {
            $apiKey = $this->apiKey;
        }

        if ($this->sessionId = $this->soapClient->login($apiUser, $apiKey)) {
            return true;
        }

        return false;
    }
1029055
public function getById($webhook, $params = array(), $options = array())
    {
        $path = sprintf("/webhooks/%s", $webhook);
        return $this->client->get($path, $params, $options);
    }
1116693
public function get($webhookId, array $fields = array())
    {
        $params = array();
        if (!empty($fields)) {
            $params['fields'] = implode(',', $fields);
        }
        $response = $this->request('/admin/webhooks/'.$webhookId.'.json', 'GET', $params);
        return $this->createObject(Webhook::class, $response['webhook']);
    }
1233163
public static function cityList($apikey, $cityName)
    {
        $url = self::WEATHER_API . '/citylist';

        return self::send($url, ['cityname' => $cityName], ["apikey: $apikey"]);
    }
972617
public static function make(string $apiKey, ?string $signatureKey = null)
    {
        return new static(Discovery::client(), $apiKey, $signatureKey);
    }
1292132
public function getAccessToken($apiKey, $apiSecret, $username, $password)
    {
        $response = $this->guzzle->request('POST', self::ENDPOINT, [
            'auth' => [$apiKey, $apiSecret],
            'form_params' => [
                'grant_type' => 'password',
                'username' => $username,
                'password' => $password,
            ],
        ]);

        $data = json_decode((string) $response->getBody(), true);

        $token = $data['access_token'];
        $expiry = new \DateTime('@' . (time() + $data['expires_in']));

        return new AccessToken($token, $expiry);
    }
1296329
public static function make($apiKey = null, $registerDefaultCallback = true)
    {
        $config = new Config($apiKey ?: getenv('AFTERBUG_API_KEY'));

        $client = new static($config, static::makeGuzzle($config));

        if ($registerDefaultCallback) {
            $client->registerDefaultCallbacks();
        }

        return $client;
    }
365155
def create_webhook(self, events, url, payload_format):
        """"""
        body = {
            "Events": events,
            "Url": url,
            "PayloadFormat": payload_format}
        response = self._post(self.uri_for("webhooks"), json.dumps(body))
        return json_to_py(response)
386532
public static function get_shipping_rates($params = null, $apiKey = null)
    {
        $class = get_class();
        $id = $params['id'];
        return self::_scopedGet($class, $id, $params, $apiKey = null);
    }
679438
public function commandsHandler($webhook = false, array $params = [])
    {
        if ($webhook) {
            $update = $this->getWebhookUpdate();
            $this->processCommand($update);

            return $update;
        }

        $updates = $this->getUpdates($params);
        $highestId = -1;

        foreach ($updates as $update) {
            $highestId = $update->getUpdateId();
            $this->processCommand($update);
        }

        //An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id.
        if ($highestId != -1) {
            $params = [];
            $params['offset'] = $highestId + 1;
            $params['limit'] = 1;
            $this->markUpdateAsRead($params);
        }

        return $updates;
    }
507562
public function authenticate($apiKey, $apiSecret)
    {
        $this->auth[0] = $apiKey;
        $this->auth[1] = $apiSecret;

        return $this;
    }