Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/indeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ public function __construct($publisher, $version = "2"){
}

public function search($args){
return $this->process_request(self::API_SEARCH_ENDPOINT, $this->validate_args(self::$API_SEARCH_REQUIRED, $args));
$valid_args = $this->validate_args(self::$API_SEARCH_REQUIRED, $args);
if (!is_array($valid_args)) {
return $valid_args;
}

return $this->process_request(self::API_SEARCH_ENDPOINT, $valid_args);
}

public function jobs($args){
$valid_args = $this->validate_args(self::$API_JOBS_REQUIRED, $args);
if (!is_array($valid_args)) {
return $valid_args;
}

$valid_args["jobkeys"] = implode(",", $valid_args['jobkeys']);
return $this->process_request(self::API_JOBS_ENDPOINT, $valid_args);
}
Expand Down Expand Up @@ -49,13 +58,14 @@ private function validate_args($required_fields, $args){
}
}
if(!$has_one_required){
throw new Exception(sprintf("You must provide one of the following %s", implode(",", $field)));
$error = sprintf("You must provide one of the following %s", implode(",", $field));
return $error;
}
} elseif(!array_key_exists($field, $args)){
throw new Exception("The field $field is required");
return "The field $field is required";
}
}
return $args;
}

}
}