Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting one contact #10

Open
JensKirk opened this issue May 13, 2020 · 15 comments
Open

Getting one contact #10

JensKirk opened this issue May 13, 2020 · 15 comments

Comments

@JensKirk
Copy link

JensKirk commented May 13, 2020

Hi :-)

I want to get one existing contact but get I all contacts listed by doing this:

		$params = array( 
			'Name' 		=> $customer->name,
			'CountryKey' 	=> $customer->country_code,
			'Email' 	=> $customer->email,
			'IsPerson'	=> True
		);

		$contacts = Dinero::Client()->contacts()->get($params);

What to modify so I only get a specific contact based on the 4 pieces of info from the webshop?

I am able to create contacts, products and invoices but not yet getting a contact.

@LasseRafn
Copy link
Owner

LasseRafn commented May 13, 2020

Hi there, sadly the wrapper currently don't support an array of $params in get() so I would try doing this instead:

$contacts = Dinero::Client()->contacts()->get( 
    sprintf("?queryFilter=Name eq '%s';CountryKey eq '%s';Email eq '%s';IsPerson eq 'True'", $customer->name, $customer->country_code, $customer->email)
);

Basically you want to put query parameters in the get(...) method, and use the queryFilter from Dinero :)

Docs: https://api.dinero.dk/docs#filters

@LasseRafn
Copy link
Owner

Ala dette:

$contacts = Dinero::Client()->contacts()->get("?queryFilter=Name eq 'Test';CountryKey eq 'DK';Email eq '[email protected]';IsPerson eq 'True'");

@JensKirk
Copy link
Author

Okay - thank you :-)

@JensKirk
Copy link
Author

JensKirk commented May 13, 2020

It is still just listing all contacts:

$contacts = Dinero::Client()->contacts()->get("?queryFilter=Name eq '".$customer->name."';CountryKey eq 'DK';Email eq '".$customer->email."';IsPerson eq 'True'");

@JensKirk
Copy link
Author

JensKirk commented May 13, 2020

Even this does not get the specific contact:

$contacts = Dinero::Client()->contacts()->get("?queryFilter=ContactGuid+eq+'f5a29994-bd7a-472f-9201-33514c0069ea'");

@JensKirk
Copy link
Author

Is it correct that GET call in this wrapper uses the LIST endpoint?

If so can this wrapper be improved with the GET endpoint?

We need to have find specific contacts in a easy way :-)

@LasseRafn
Copy link
Owner

Ah I see! You can use the find method instead of get — it accepts a GUID and will give you just that one contact 😄

@LasseRafn
Copy link
Owner

Dinero::Client()->contacts()->find($guid)

@JensKirk
Copy link
Author

JensKirk commented May 14, 2020

Thank you again :-)

But I also need to find a specific contact when the Guid is not known.

I have tried with but it is not working:

  $contacts = Dinero::Client()->contacts()->get("?queryFilter=Name+eq+'".$customer->person."';CountryKey+eq+'DK';Email+eq+'".$customer->email."';IsPerson+eq+'True'");

It is just returning all contacts.

@JensKirk JensKirk changed the title Geting one contact Getting one contact May 14, 2020
@LasseRafn
Copy link
Owner

Odd! Maybe this is an issue in the Dinero API or maybe the CountryKey is breaking the filter (as it is not supported)

https://api.dinero.dk/openapi/index.html#tag/Contacts/paths/~1v1~1{organizationId}~1contacts/get

Filter specific for contacts. Filtering can be applied to following fields: ExternalReference,Name, Email, VatNumber, EanNumber, IsPerson. See API documentation for filtering format. If left empty no filtering is applied.

@JensKirk
Copy link
Author

JensKirk commented May 14, 2020

Dinero API support is saying:

Dinero Support (Dinero)
14. maj 2020 12.11.34 CEST
Hej Jens

Der ser ud til at det library i bruger ikke sender dit query parameter med. Når jeg henter logs frem for dit firma id du har angivet så ser kaldende sådan her ud

https://api.dinero.dk/v1/xxxxxxx/contacts?fields=ContactGuid,CreatedAt,UpdatedAt,DeletedAt,IsDebitor,IsCreditor,ExternalReference,Name,Street,ZipCode,City,CountryKey,Phone,Email,Webpage,AttPerson,VatNumber,EanNumber,PaymentConditionType,PaymentConditionNumberOfDays,IsPerson&page=0&pageSize=100

QueryFilter parameteret er altså ikke med i requested

@JensKirk
Copy link
Author

The issue is the same with getting one product.

This code lists all products:

$productDinero = Dinero::Client()->products()->get("?queryFilter=Name+eq+'".$orderItem->product_name."'");

@JensKirk
Copy link
Author

Any news? :-)

@LasseRafn
Copy link
Owner

LasseRafn commented May 16, 2020 via email

@JensKirk
Copy link
Author

JensKirk commented May 16, 2020

Hi :-) I did manage to improve the code so it is working by doing this:

public function get($query) {
	$response = $this->builder->get($this->buildParameters()."&queryFilter=".$query);

	return $response;
}

And calling it with:

  $contactDinero = Dinero::Client()->contacts()->get("Email+eq+'".$customer->email."'");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants