Plugin Directory

Changeset 2308051


Ignore:
Timestamp:
05/19/2020 02:11:17 PM (6 years ago)
Author:
yaroslawww
Message:

v0.0.5

Location:
wp-bullhorn-staffing
Files:
5 edited
9 copied

Legend:

Unmodified
Added
Removed
  • wp-bullhorn-staffing/tags/0.0.5/bootstrap.php

    r2307897 r2308051  
    44 * Plugin URI:
    55 * Description: Bullhorn Staffing synchronisation plugin
    6  * Version: 0.0.4
     6 * Version: 0.0.5
    77 * Author: Think studio
    88 * Author URI: https://think.studio/
  • wp-bullhorn-staffing/tags/0.0.5/src/Domain/Entities/AbstractBhEntity.php

    r2307839 r2308051  
    3535    {
    3636        return 'wpbstaff_entity_' . substr(strrchr(static::class, "\\"), 1) . '_' . $id;
     37    }
     38
     39    /**
     40     * @see https://bullhorn.github.io/rest-api-docs/#get-search
     41     * @param array $query
     42     * @return |null
     43     */
     44    public static function search(array $query = [])
     45    {
     46        $obj = new static();
     47        $response = \WPBullhornStaffing::instance()->request(
     48            'GET',
     49            'search/' . $obj->getEntityType(),
     50            [
     51                'query' => array_merge([
     52                    'query' => 'isDeleted:0',
     53                    'fields' => implode(',', array_merge(
     54                        $obj->fields,
     55                        array_keys($obj->fieldsMap)
     56                    ))
     57                ], $query)
     58            ]
     59        );
     60        if (is_wp_error($response)) {
     61            error_log($response->get_error_message());
     62            return null;
     63        }
     64
     65        return $response->data;
    3766    }
    3867
  • wp-bullhorn-staffing/tags/0.0.5/src/Domain/Options/AbstractOptions.php

    r2307839 r2308051  
    2525
    2626
    27     protected function getPaginatedIdList(): array
     27    protected function getPaginatedIdList($query = []): array
    2828    {
    2929        $data = [];
     
    3434                'options/' . $this->getOptionsType(),
    3535                [
    36                     'query' => [
    37                         'fields' => '*',
    38                         'meta' => 'full',
     36                    'query' => array_merge($query, [
    3937                        'count' => 300,
    4038                        'start' => $start
    41                     ]
     39                    ])
    4240                ]
    4341            );
     
    5755    abstract public function getOptionsType(): string;
    5856
    59     public function getOptions(): array
     57    public function getOptions($forceFetch = false, $cacheTime = DAY_IN_SECONDS): array
    6058    {
    6159        $transientName = 'wpbstaff_options_' . $this->getOptionsType();
     60        $data = null;
    6261
    63         $data = get_transient( $transientName );
     62        if(!$forceFetch) {
     63            $data = get_transient($transientName);
     64        }
    6465
    6566        if(!$data) {
    6667            $data = $this->getPaginatedIdList();
    6768            if($data && !empty($data)) {
    68                 set_transient($transientName, $data, DAY_IN_SECONDS);
     69                set_transient($transientName, $data, $cacheTime);
    6970            }
    7071        }
  • wp-bullhorn-staffing/trunk/bootstrap.php

    r2307897 r2308051  
    44 * Plugin URI:
    55 * Description: Bullhorn Staffing synchronisation plugin
    6  * Version: 0.0.4
     6 * Version: 0.0.5
    77 * Author: Think studio
    88 * Author URI: https://think.studio/
  • wp-bullhorn-staffing/trunk/src/Domain/Entities/AbstractBhEntity.php

    r2307839 r2308051  
    3535    {
    3636        return 'wpbstaff_entity_' . substr(strrchr(static::class, "\\"), 1) . '_' . $id;
     37    }
     38
     39    /**
     40     * @see https://bullhorn.github.io/rest-api-docs/#get-search
     41     * @param array $query
     42     * @return |null
     43     */
     44    public static function search(array $query = [])
     45    {
     46        $obj = new static();
     47        $response = \WPBullhornStaffing::instance()->request(
     48            'GET',
     49            'search/' . $obj->getEntityType(),
     50            [
     51                'query' => array_merge([
     52                    'query' => 'isDeleted:0',
     53                    'fields' => implode(',', array_merge(
     54                        $obj->fields,
     55                        array_keys($obj->fieldsMap)
     56                    ))
     57                ], $query)
     58            ]
     59        );
     60        if (is_wp_error($response)) {
     61            error_log($response->get_error_message());
     62            return null;
     63        }
     64
     65        return $response->data;
    3766    }
    3867
  • wp-bullhorn-staffing/trunk/src/Domain/Options/AbstractOptions.php

    r2307839 r2308051  
    2525
    2626
    27     protected function getPaginatedIdList(): array
     27    protected function getPaginatedIdList($query = []): array
    2828    {
    2929        $data = [];
     
    3434                'options/' . $this->getOptionsType(),
    3535                [
    36                     'query' => [
    37                         'fields' => '*',
    38                         'meta' => 'full',
     36                    'query' => array_merge($query, [
    3937                        'count' => 300,
    4038                        'start' => $start
    41                     ]
     39                    ])
    4240                ]
    4341            );
     
    5755    abstract public function getOptionsType(): string;
    5856
    59     public function getOptions(): array
     57    public function getOptions($forceFetch = false, $cacheTime = DAY_IN_SECONDS): array
    6058    {
    6159        $transientName = 'wpbstaff_options_' . $this->getOptionsType();
     60        $data = null;
    6261
    63         $data = get_transient( $transientName );
     62        if(!$forceFetch) {
     63            $data = get_transient($transientName);
     64        }
    6465
    6566        if(!$data) {
    6667            $data = $this->getPaginatedIdList();
    6768            if($data && !empty($data)) {
    68                 set_transient($transientName, $data, DAY_IN_SECONDS);
     69                set_transient($transientName, $data, $cacheTime);
    6970            }
    7071        }
Note: See TracChangeset for help on using the changeset viewer.