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

Demo Code. #2

Open
PremierDevs opened this issue Jun 29, 2023 · 2 comments
Open

Demo Code. #2

PremierDevs opened this issue Jun 29, 2023 · 2 comments
Assignees

Comments

@PremierDevs
Copy link

I was wondering if you could provide some demo code to login and search. I have less than 5 hours with elixir and am struggling to make sense of the docs.

@jdav-dev
Copy link
Owner

Sure thing. I have a branch where I'm updating things for the first time in 3 years. I'll be sure to include example usage before merging that branch.

@jdav-dev jdav-dev self-assigned this Jun 30, 2023
@jdav-dev
Copy link
Owner

I didn't get back to this as quickly as I anticipated, so here's a quick example.

Fill out the ExRets.Credentials struct:

credentials = %ExRets.Credentials{
  system_id: :my_mls,
  login_uri: "https://example.com/login",
  username: "my username",
  password: "my password",
  user_agent: "might have a user agent",
  user_agent_password: "might have a user agent password",
  rets_version: "RETS/1.8"
}

Login with the credentials to get a RETS client:

{:ok, %ExRets.RetsClient{} = rets_client} = ExRets.login(credentials)

Fill out the ExRets.SearchArguments struct:

search_arguments = %ExRets.SearchArguments{
  search_type: "Property",
  class: "CrossProperty",
  select: "ListingKeyNumeric",
  limit: "NONE",
  query: "(ModificationTimestamp=2023-07-12T17:32:41Z+)",
  count: :include_record_count
}

Perform the RETS search:

{:ok, rets_response} = ExRets.search(rets_client, search_arguments)

If all goes well, rets_response.response will contain the ExRets.SearchResponse struct which has the response columns, rows, count, etc.

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