How to get all the tasks for a specific appitem - podio

I have spent the last 4 hrs trying to figure out how to get the list of Tasks that reference a specific AppItem.
The following do NOT work:
// Doesn't work
// $tasks = PodioTask::get_all(array(
// 'reference' => 'rmticket:' . $rmt->item_id,
// ));
// $tasks = PodioTask::get_all(array(
// 'reference' => array('type' => 'rmticket', 'id' => $rmt->item_id),
// ));
// $tasks = PodioTask::get_all(array(
// 'item' => $rmt->item_id,
// ));
// $tasks = PodioTask::get_all(array(
// 'ref_id' => $rmt->item_id,
// ));
Documentation here: https://developers.podio.com/doc/tasks/get-tasks-77949
says that the parameter for this is:
reference
The list of references on the form "type:id" separated by semi-colon.
That is the first thing I tried, and I get the following error:
Uncaught PodioBadRequestError: "Invalid value "rmticket" (string): must be one of {'comment', 'rating', 'invoice', 'campaign', 'app_revision', 'app', 'share', 'system', 'hook', 'tag', 'voucher', 'file', 'flow_effect', 'vote', 'partner', 'message', 'conversation', 'share_install', 'form', 'space_member_request', 'space', 'notification', 'auth_client', 'question', 'integration', 'payment', 'subscription', 'live', 'label', 'answer', 'icon', 'location', 'status', 'org_member', 'widget', 'extension_installation', 'file_service', 'app_field', 'alert', 'profile', 'user', 'task_action', 'org', 'condition_set', 'embed', 'condition', 'space_member', 'identity', 'item_participation', 'task', 'extension', 'linked_account', 'grant', 'flow', 'batch', 'contract', 'project', 'item', 'connection', 'flow_condition', 'question_answer', 'action', 'item_revision', 'voting', 'promotion', 'bulletin', 'view'
-- Andrew.
UPDATE:
I also have tried the following:
// $tasks = PodioTask::get_all(array(
// 'grouping' => 'rmticket:' . $rmt->item_id,
// ));
// Fatal error: Uncaught PodioBadRequestError: "Invalid value "rmticket:720406510" (string): Must be one of ['due_date', 'completed_on', 'reference', 'space', 'app', 'responsible', 'created_by', 'label', 'org' in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
// $tasks = PodioTask::get_all(array(
// 'grouping' => 'reference',
// 'item_id' => $rmt->item_id,
// ));
// Fatal error: Uncaught PodioBadRequestError: "Invalid filter item_id" Request URL: http://api.podio.com/task/?grouping=reference&item_id=720406510 Stack Trace: #0 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php(349): Podio::request('GET', '/task/', Array, Array) #1 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/models/PodioTask.php(100): Podio::get('/task/', Array) #2 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(217): PodioTask::get_all(Array) #3 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(152): rmtCreateTask(Object(AvcPodioItem), 'Carpet Cleaning', 10, 3) #4 /home/avcorp/vhosts/pubvps/podio_rmticket/poll/rmticket_poll.php(54): test_task_creation() #5 {main} thrown in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
// $tasks = PodioTask::get_all(array(
// 'grouping' => 'reference',
// 'item' => $rmt->item_id,
// ));
// Fatal error: Uncaught PodioBadRequestError: "Invalid filter item" Request URL: http://api.podio.com/task/?grouping=reference&item=720406510 Stack Trace: #0 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php(349): Podio::request('GET', '/task/', Array, Array) #1 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/models/PodioTask.php(100): Podio::get('/task/', Array) #2 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(222): PodioTask::get_all(Array) #3 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(152): rmtCreateTask(Object(AvcPodioItem), 'Carpet Cleaning', 10, 3) #4 /home/avcorp/vhosts/pubvps/podio_rmticket/poll/rmticket_poll.php(54): test_task_creation() #5 {main} thrown in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
// $tasks = PodioTask::get_all(array(
// 'grouping' => 'reference',
// ));
// Fatal error: Uncaught PodioBadRequestError: "Query not restrictive enough, must filter on either org, space, app, responsible, reference, created_by or completed_by" Request URL: http://api.podio.com/task/?grouping=reference Stack Trace: #0 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php(349): Podio::request('GET', '/task/', Array, Array) #1 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/models/PodioTask.php(100): Podio::get('/task/', Array) #2 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(227): PodioTask::get_all(Array) #3 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(152): rmtCreateTask(Object(AvcPodioItem), 'Carpet Cleaning', 10, 3) #4 /home/avcorp/vhosts/pubvps/podio_rmticket/poll/rmticket_poll.php(54): test_task_creation() #5 {main} thrown in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
// $tasks = PodioTask::get_all(array(
// 'grouping' => 'reference:' . $rmt->item_id,
// ));
// Fatal error: Uncaught PodioBadRequestError: "Invalid value "reference:720406510" (string): Must be one of ['due_date', 'completed_on', 'reference', 'space', 'app', 'responsible', 'created_by', 'label', 'org' in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
// $tasks = PodioTask::get_all(array(
// 'item' => array('item_id' => $rmt->item_id),
// ));
// Fatal error: Uncaught PodioBadRequestError: "Invalid filter item" Request URL: http://api.podio.com/task/?item= Stack Trace: #0 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php(349): Podio::request('GET', '/task/', Array, Array) #1 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/models/PodioTask.php(100): Podio::get('/task/', Array) #2 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(238): PodioTask::get_all(Array) #3 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(152): rmtCreateTask(Object(AvcPodioItem), 'Carpet Cleaning', 10, 3) #4 /home/avcorp/vhosts/pubvps/podio_rmticket/poll/rmticket_poll.php(54): test_task_creation() #5 {main} thrown in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
// $tasks = PodioTask::get_all(array(
// 'grouping' => 'reference',
// 'ref_id' => $rmt->item_id,
// ));
// Fatal error: Uncaught PodioBadRequestError: "Invalid filter ref_id" Request URL: http://api.podio.com/task/?grouping=reference&ref_id=720406510 Stack Trace: #0 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php(349): Podio::request('GET', '/task/', Array, Array) #1 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/models/PodioTask.php(100): Podio::get('/task/', Array) #2 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(243): PodioTask::get_all(Array) #3 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(152): rmtCreateTask(Object(AvcPodioItem), 'Carpet Cleaning', 10, 3) #4 /home/avcorp/vhosts/pubvps/podio_rmticket/poll/rmticket_poll.php(54): test_task_creation() #5 {main} thrown in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
// $tasks = PodioTask::get_all(array(
// 'grouping' => 'reference',
// 'reference' => 'rmticket:' . $rmt->item_id,
// ));
// Fatal error: Uncaught PodioBadRequestError: "Invalid value "rmticket" (string): must be one of {'comment', 'rating', 'invoice', 'campaign', 'app_revision', 'app', 'share', 'system', 'hook', 'tag', 'voucher', 'file', 'flow_effect', 'vote', 'partner', 'message', 'conversation', 'share_install', 'form', 'space_member_request', 'space', 'notification', 'auth_client', 'question', 'integration', 'payment', 'subscription', 'live', 'label', 'answer', 'icon', 'location', 'status', 'org_member', 'widget', 'extension_installation', 'file_service', 'app_field', 'alert', 'profile', 'user', 'task_action', 'org', 'condition_set', 'embed', 'condition', 'space_member', 'identity', 'item_participation', 'task', 'extension', 'linked_account', 'grant', 'flow', 'batch', 'contract', 'project', 'item', 'connection', 'flow_condition', 'question_answer', 'action', 'item_revision', 'voting', 'promotion', 'bulletin', 'view' in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
// $tasks = PodioTask::get_all(array(
// 'grouping' => 'reference',
// 'reference' => $rmt->item_id,
// ));
// Fatal error: Uncaught PodioBadRequestError: "Expected references on the form type:id" Request URL: http://api.podio.com/task/?grouping=reference&reference=720406510 Stack Trace: #0 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php(349): Podio::request('GET', '/task/', Array, Array) #1 /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/models/PodioTask.php(100): Podio::get('/task/', Array) #2 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(255): PodioTask::get_all(Array) #3 /home/avcorp/vhosts/pubvps/podio_rmticket/rmticket_util.php(152): rmtCreateTask(Object(AvcPodioItem), 'Carpet Cleaning', 10, 3) #4 /home/avcorp/vhosts/pubvps/podio_rmticket/poll/rmticket_poll.php(54): test_task_creation() #5 {main} thrown in /home/avcorp/vhosts/pubvps/vendor/podio/podio-php/lib/Podio.php on line 289
The last one is the closest, but as you can see, while I CANNOT send a 'reference' => type:id it seems to require it.
Is this a bug in Podio's API?
-- Andrew.

Finally figured it out (no thanks to the Podio documentation).
This works:
$tasks = PodioTask::get_all(array(
'grouping' => 'reference',
'reference' => 'item:' . $rmt->item_id,
));
Apparently, the "type" they are looking for is NOT the type of the Item, but one of a list of possible "reference" types. Course, that COULD have been documented, but as with much of Podio's API docs, they have LOTS of docs, but much of it is just top-level "basic" docs with little detail and lots of "hand-waving"...frustrating...

Related

Setting unknown property: yii\log\Logger::targets

After Installed the Yii in my system when I try to run it getting this error.
Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: yii\log\Logger::targets
Here is some of the documentation I created while implementing logging in Yii, it might be of your help:
========================= Configure xampp to send the emails from localhost code ==========================================
Changes for C:\xampp\php\php.ini file:
search for [mail function]:
[mail function]
SMTP=localhost to SMTP=smtp.gmail.com
smtp_port=587
sendmail_from=me#example.com to sendmail_from=your email address
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off
mail.log = syslog
Changes for C:\xampp\sendmail\sendmail.ini:
search for [sendmail]:
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username=same as "sendmail_from" in php.ini file
auth_password=generated password for the email account
force_sender= same as "auth_username" in this file
================================================ Restart Xampp Server =====================================================
=================================================== Add table in DB =======================================================
drop table if exists "log";
create table "log"
(
"id" number(20) NOT NULL PRIMARY KEY,
"level" integer,
"category" varchar(255),
"log_time" number,
"prefix" text,
"message" text,
key "idx_log_level" ("level"),
key "idx_log_category" ("category")
);
============================================ Configuration in Yii2 project ================================================
add in "components" array in app\config\console.php and app\config\web.php both files:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => 'your email address (for testing on localhost use same as in ini files)',
'password' => 'generated password',
'port' => 587,
'encryption' => 'tls',
],
], //end of mailer
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning','info'],
],
[
'class' => 'yii\log\DbTarget',
'levels' => ['error', 'warning','info'],
],
[
'class' => 'yii\log\EmailTarget',
'mailer' => 'mailer',
'levels' => ['error', 'warning','info'],
//'categories' => ['yii\db\*'],
'message' => [
'from' => ['your email address(for testing on localhost use same as in ini files)'],
'to' => ['receiptent email address'],
],
],
], // end of targets
'flushInterval' => 1,
], //end of logs
//------------------------ web.php (log configuration setup) -------------------------//
//categories name would be later assgined to messages:
Yii::info($message, 'userNotification');

Mollie applicationfee's

for a customer I need to charge an applicationFee for each order that has been processed on their site from the sub customers. The whole code is working with authentication and everything.
But from the moment I'm adding:
'applicationFee' => $applicationFee
to the call I receive this error:
Error executing API call (422: Unprocessable Entity): Unable to process application request for this account. Documentation: https://docs.mollie.com/guides/handling-errors"
The content of "$applicationFee" is correct, that I was able to check already.
The $shop_mollie_data->profile_id containts the different websiteprofileId's found on the Mollie dashboard.
$provider = new MollieConnectProvider($request, $clientId, $clientSecret, $redirectUrl);
$newAccessToken = $provider->getRefreshTokenResponse($shop_mollie_data->refresh_token);
$mollie = new MollieApiClient();
$mollie->setAccessToken($newAccessToken['access_token']);
$payment = $mollie->payments->create([
'amount' => [
'currency' => 'EUR',
'value' => (string) (sprintf("%.2f", $order_total))
],
'description' => ucfirst($shop->name) . ' - Order #' . $order_nm,
'webhookUrl' => $url_callback,
'redirectUrl' => $url_success,
'method' => 'bancontact',
'locale' => $language_id,
'metadata' => [
"order_id" => $ref,
"shop id" => $shop->id
],
'profileId' => $shop_mollie_data->profile_id,
'testmode' => true,
'applicationFee' => $applicationFee
]);

SQLSTATE[HY000] [1049] on YiiFramework

$ yii migrate
Yii Migration Tool (based on Yii v2.0.13-dev)
Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [1049]
Unknown database 'yii''
in E:\laragon\www\website\vendor\yiisoft\yii2\db\Connection.php:586
Stack trace:
#0 E:\laragon\www\website\vendor\yiisoft\yii2\db\Connection.php(932): yii\db\Connection->open()
#1 E:\laragon\www\website\vendor\yiisoft\yii2\db\Connection.php(919): yii\db\Connection->getMasterPdo()
#2 E:\laragon\www\website\vendor\yiisoft\yii2\db\Command.php(219): yii\db\Connection->getSlavePdo()
#3 E:\laragon\www\website\vendor\yiisoft\yii2\db\Command.php(1031): yii\db\Command->prepare(true)
#4 E:\laragon\www\website\vendor\yiisoft\yii2\db\Command.php(362): yii\db\Command->queryInternal('fetchAll', NULL)
#5 E:\laragon\www\website\vendor\yiisoft\yii2\db\mysql\Schema.php(320): yii\db\Command->queryAll()
#6 E:\laragon\www\website\vendor\yiisoft\yii2\db\mysql\Schema.php(111): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 E:\laragon\www\website\vendor\yiisoft\yii2\db\Schema.php(661): yii\db\mysql\Schema->loadTableSchema('migration')
#8 E:\laragon\www\website\vendor\yiisoft\yii2\db\Schema.php(174): yii\db\Schema->getTableMetadata('{{%migration}}', 'schema', true)
#9 E:\laragon\www\website\vendor\yiisoft\yii2\console\controllers\MigrateController.php(201): yii\db\Schema->getTableSchema('{{%migration}}', true)
#10 E:\laragon\www\website\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(864): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
#11 E:\laragon\www\website\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(166): yii\console\controllers\BaseMigrateController->getNewMigrations()
#12 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#13 E:\laragon\www\website\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#14 E:\laragon\www\website\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#15 E:\laragon\www\website\vendor\yiisoft\yii2\console\Controller.php(135): yii\base\Controller->runAction('', Array)
#16 E:\laragon\www\website\vendor\yiisoft\yii2\base\Module.php(528): yii\console\Controller->runAction('', Array)
#17 E:\laragon\www\website\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate', Array)
#18 E:\laragon\www\website\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate', Array)
#19 E:\laragon\www\website\vendor\yiisoft\yii2\base\Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#20 E:\laragon\www\website\yii(20): yii\base\Application->run()
#21 {main}
this my db
return [
'class' => 'yii\db\Connection', 'driverName' => 'mysql',
'dsn' => 'mysql:host=localhost;dbname=yii',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
// Schema cache options (for production environment)
//'enableSchemaCache' => true,
//'schemaCacheDuration' => 60,
//'schemaCache' => 'cache', ];
The error message means you need to create a database name 'yii'.
Just use Menu > MySQL > Create database to create the database.

ExAws not working on production release (Phoenix/Arc/ExAws)

I've been trying to create an uploader for avatars, but I've been facing some issues, the code works perfectly on dev, but on the production release, I get this error:
=SUPERVISOR REPORT==== 8-Jul-2016::22:35:41 ===
Supervisor: {local,'Elixir.ExAws.Supervisor'}
Context: child_terminated
Reason: {#{'__exception__' => true,
'__struct__' => 'Elixir.Poison.SyntaxError',
message => <<"Unexpected token: <">>,
token => <<"<">>},
[{'Elixir.Poison.Parser','parse!',2,
[{file,"lib/poison/parser.ex"},{line,56}]},
{'Elixir.Poison','decode!',2,
[{file,"lib/poison.ex"},{line,83}]},
{'Elixir.ExAws.InstanceMeta',security_credentials,1,
[{file,"lib/ex_aws/instance_meta.ex"},{line,16}]},
{'Elixir.ExAws.Config.AuthCache',refresh_config,2,
[{file,"lib/ex_aws/config/auth_cache.ex"},{line,37}]},
{'Elixir.ExAws.Config.AuthCache',handle_call,3,
[{file,"lib/ex_aws/config/auth_cache.ex"},{line,27}]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,615}]},
{gen_server,handle_msg,5,
[{file,"gen_server.erl"},{line,647}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,247}]}]}
Offender: [{pid,<0.2009.0>},
{id,'Elixir.ExAws.Config.AuthCache'},
{mfargs,
{'Elixir.ExAws.Config.AuthCache',start_link,
[[{name,'Elixir.ExAws.Config.AuthCache'}]]}},
{restart_type,permanent},
{shutdown,5000},
{child_type,worker}]
22:35:41.624 [error] Ranch protocol #PID<0.2011.0> (:cowboy_protocol) of listener MyApp.Endpoint.HTTP terminated
** (exit) exited in: GenServer.call(ExAws.Config.AuthCache, {:refresh_config, %ExAws.S3{config: %{access_key_id: [{:system, "AWS_ACCESS_KEY_ID"}, :instance_role], host: %{"ap-northeast-1" =>
"s3-ap-northeast-1.amazonaws.com", "ap-southeast-1" => "s3-ap-southeast-1.amazonaws.com", "ap-southeast-2" => "s3-ap-southeast-2.amazonaws.com", "eu-central-1" => "s3-eu-central-1.amazonaws.c
om", "eu-west-1" => "s3-eu-west-1.amazonaws.com", "sa-east-1" => "s3-sa-east-1.amazonaws.com", "us-east-1" => "s3.amazonaws.com", "us-west-1" => "s3-us-west-1.amazonaws.com", "us-west-2" => "
s3-us-west-2.amazonaws.com"}, http_client: ExAws.Request.HTTPoison, json_codec: Poison, region: "us-east-1", scheme: "https://", secret_access_key: [{:system, "AWS_SECRET_ACCESS_KEY"}, :insta
nce_role]}, service: :s3}}, 5000)
** (EXIT) an exception was raised:
** (Poison.SyntaxError) Unexpected token: <
(poison) lib/poison/parser.ex:56: Poison.Parser.parse!/2
(poison) lib/poison.ex:83: Poison.decode!/2
(ex_aws) lib/ex_aws/instance_meta.ex:16: ExAws.InstanceMeta.security_credentials/1
(ex_aws) lib/ex_aws/config/auth_cache.ex:37: ExAws.Config.AuthCache.refresh_config/2
(ex_aws) lib/ex_aws/config/auth_cache.ex:27: ExAws.Config.AuthCache.handle_call/3
(stdlib) gen_server.erl:615: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:647: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Thanks.
Your stack trace says that Poison, a dep that ExAws uses, failed to decode a json. If you check the module that made that call (lib/ex_aws/instance_meta.ex, you can read it here), you'll find that it communicates with Amazon to check your credentials.
The most probable thing is that your configuration is incorrect and Amazon is sending you an error message formatted as an XML or HTML (both begin with <).
ExAws config depends on env vars, so that's also probably why it works on dev, but not on production.

Custom error message for the "file required" in zf2

This is config for the input factory:
'name' => 'file',
'type' => 'Zend\InputFilter\FileInput',
'required' => true,
When I submit the form without "file" there's no error showing up saying something like "the field file is required". However, if I add the "error_message" the error is showing up, but it overrides other error messages from other validators in this input. When working with regular inputs I add the following validator:
[
'name' => 'not_empty',
'options' => [
'message' => 'Field is required'
]
]
But, I can't do this with FileInput.
Is there any way to set the custom message for the required field in case if "FileInput" is used?