bridge_interactive 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/CHANGELOG.md +17 -0
- data/LICENSE.txt +21 -0
- data/README.md +130 -0
- data/Rakefile +4 -0
- data/lib/bridge_interactive/.DS_Store +0 -0
- data/lib/bridge_interactive/api.rb +92 -0
- data/lib/bridge_interactive/bridge/agent.rb +37 -0
- data/lib/bridge_interactive/bridge/dataset.rb +29 -0
- data/lib/bridge_interactive/bridge/listing.rb +37 -0
- data/lib/bridge_interactive/bridge/office.rb +37 -0
- data/lib/bridge_interactive/bridge/open_house.rb +37 -0
- data/lib/bridge_interactive/configuration.rb +11 -0
- data/lib/bridge_interactive/error.rb +19 -0
- data/lib/bridge_interactive/reso/.DS_Store +0 -0
- data/lib/bridge_interactive/reso/lookup.rb +30 -0
- data/lib/bridge_interactive/reso/member.rb +37 -0
- data/lib/bridge_interactive/reso/office.rb +37 -0
- data/lib/bridge_interactive/reso/open_house.rb +38 -0
- data/lib/bridge_interactive/reso/property.rb +37 -0
- data/lib/bridge_interactive/version.rb +5 -0
- data/lib/bridge_interactive.rb +28 -0
- data/sig/bridge_interactive.rbs +4 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9998b620340cc9f0b0e9139815bce516c90bb3141ded1e451bced8572ed8807a
|
4
|
+
data.tar.gz: f17ebe3021c3cd6832ea9e82c18b1bacb0674b32194b2801fc78ffa4f27e2cf1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5fe05ae70f6c967399db0880f1bc03063edd5bcd85428936e328d75b01ccdd700acfe67ffc8ef4d2f580e71f9f9cd3c4004cb574c97bf06c642fbee6b90a8b0d
|
7
|
+
data.tar.gz: 5a19ee37020597e35e878b79f5d96a7fe13a608b997b67462d94039d0b4a3b48af3b089b6248246bae4092eeb5fcc857a4b65ce53e48d1a747eb7ea6f21b015b
|
data/.DS_Store
ADDED
Binary file
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
## 0.1.0
|
2
|
+
|
3
|
+
API Client for use with Bridge Interactive's RESO Web API and Bridge Web API
|
4
|
+
|
5
|
+
#### Includes RESO Web API endpoints for
|
6
|
+
- property all/find
|
7
|
+
- member all/find
|
8
|
+
- office all/find
|
9
|
+
- open_house all/find
|
10
|
+
- lookup all
|
11
|
+
|
12
|
+
#### Includes Bridge Web API endpoints for
|
13
|
+
- listings all/find
|
14
|
+
- agents all/find
|
15
|
+
- offices all/find
|
16
|
+
- open_houses all/find
|
17
|
+
- dataset all
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Stephen Higgins
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# BridgeInteractive
|
2
|
+
|
3
|
+
BridgeInteractive is a Ruby gem that provides a unified API client for interacting with both the Bridge Web API and RESO Web API. It allows you to work with datasets, properties, members, offices, and open houses from both systems using a flexible configuration.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem 'bridge_interactive'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
gem install bridge_interactive
|
23
|
+
```
|
24
|
+
|
25
|
+
## Getting Started
|
26
|
+
|
27
|
+
Once installed, you can configure the gem with your access token and API type (either :bridge for the Bridge Web API or :reso for the RESO Web API). You can set these configurations globally or override them on a per-use basis.
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
To configure the gem globally, create an initializer in your Rails app (e.g., config/initializers/bridge_interactive.rb):
|
32
|
+
|
33
|
+
```bash
|
34
|
+
BridgeInteractive.configure do |config|
|
35
|
+
config.api_type = :bridge # or :reso
|
36
|
+
config.timeout = 30 # Timeout for API requests in seconds
|
37
|
+
config.logger = Rails.logger # Use the Rails logger, or provide your custom logger
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
### Initializing the Client
|
44
|
+
|
45
|
+
You can initialize the API client using your server_token. The api_type can be either :bridge or :reso. If not provided, the default from the configuration will be used:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
client = BridgeInteractive::API.new('your_server_token', api_type: :bridge)
|
49
|
+
```
|
50
|
+
|
51
|
+
### Fetching Datasets
|
52
|
+
|
53
|
+
For Bridge API:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
datasets = client.datasets.all
|
57
|
+
```
|
58
|
+
|
59
|
+
For RESO API, use lookup to fetch RESO-specific datasets.
|
60
|
+
|
61
|
+
### Fetching Properties or Listings
|
62
|
+
|
63
|
+
To fetch properties or listings:
|
64
|
+
|
65
|
+
```bash
|
66
|
+
# For Bridge API (listings)
|
67
|
+
listings = client.property.all('dataset_id')
|
68
|
+
|
69
|
+
# For RESO API (properties)
|
70
|
+
properties = client.property(api_type: :reso).all('dataset_id')
|
71
|
+
```
|
72
|
+
|
73
|
+
### Fetching Agents or Members
|
74
|
+
|
75
|
+
For Bridge API, agents are used, while for RESO API, members are equivalent.
|
76
|
+
|
77
|
+
```bash
|
78
|
+
# For Bridge API (agents)
|
79
|
+
agents = client.agents.all('dataset_id')
|
80
|
+
|
81
|
+
# For RESO API (members)
|
82
|
+
members = client.members.all('dataset_id')
|
83
|
+
```
|
84
|
+
|
85
|
+
### Fetching Open Houses
|
86
|
+
|
87
|
+
The OpenHouse resource is available in both APIs:
|
88
|
+
|
89
|
+
```bash
|
90
|
+
# For Bridge API
|
91
|
+
open_houses = client.open_houses.all
|
92
|
+
|
93
|
+
# For RESO API
|
94
|
+
open_houses = client.open_houses(api_type: :reso).all
|
95
|
+
```
|
96
|
+
|
97
|
+
### Error Handling
|
98
|
+
|
99
|
+
The gem raises errors when attempting to use the wrong API for certain resources. For example:
|
100
|
+
|
101
|
+
```bash
|
102
|
+
begin
|
103
|
+
lookup_data = client.lookup.all('dataset_id') # Will fail if api_type is :bridge
|
104
|
+
rescue StandardError => e
|
105
|
+
puts e.message
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
### Custom Use Cases
|
110
|
+
|
111
|
+
You can override the global configuration for specific API calls:
|
112
|
+
|
113
|
+
```bash
|
114
|
+
# Use RESO API for fetching members, overriding the global setting
|
115
|
+
members = client.members(api_type: :reso).all('dataset_id')
|
116
|
+
```
|
117
|
+
|
118
|
+
## Development
|
119
|
+
|
120
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
121
|
+
|
122
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
123
|
+
|
124
|
+
## Contributing
|
125
|
+
|
126
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gryphonandrook/bridge_interactive.
|
127
|
+
|
128
|
+
## License
|
129
|
+
|
130
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
Binary file
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require_relative 'bridge/agent'
|
2
|
+
require_relative 'bridge/dataset'
|
3
|
+
require_relative 'bridge/listing'
|
4
|
+
require_relative 'bridge/office'
|
5
|
+
require_relative 'bridge/open_house'
|
6
|
+
|
7
|
+
require_relative 'reso/lookup'
|
8
|
+
require_relative 'reso/member'
|
9
|
+
require_relative 'reso/office'
|
10
|
+
require_relative 'reso/open_house'
|
11
|
+
require_relative 'reso/property'
|
12
|
+
|
13
|
+
module BridgeInteractive
|
14
|
+
class API
|
15
|
+
attr_reader :client, :server_token
|
16
|
+
|
17
|
+
def initialize(server_token, api_type: nil)
|
18
|
+
@client = HTTPClient.new
|
19
|
+
@server_token = server_token
|
20
|
+
|
21
|
+
# Use the api_type passed in, or fall back to the globally configured api_type
|
22
|
+
@api_type = api_type || BridgeInteractive.configuration.api_type
|
23
|
+
|
24
|
+
# Apply global configuration settings to the client
|
25
|
+
@client.connect_timeout = BridgeInteractive.configuration.timeout if BridgeInteractive.configuration
|
26
|
+
end
|
27
|
+
|
28
|
+
# Fetch dataset resource
|
29
|
+
def datasets
|
30
|
+
if @api_type == :bridge
|
31
|
+
Bridge::Dataset.new(@client, @server_token)
|
32
|
+
else
|
33
|
+
log_and_return_error('datasets', 'Bridge')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Fetch lookup resource
|
38
|
+
def lookup
|
39
|
+
if @api_type == :reso
|
40
|
+
Reso::Lookup.new(@client, @server_token)
|
41
|
+
else
|
42
|
+
log_and_return_error('lookup', 'RESO')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Fetch member resource, allowing custom api_type to be passed
|
47
|
+
def member(api_type: nil)
|
48
|
+
selected_api_type = api_type || @api_type
|
49
|
+
selected_api_type == :bridge ? Bridge::Agent.new(@client, @server_token) : Reso::Member.new(@client, @server_token)
|
50
|
+
end
|
51
|
+
|
52
|
+
alias agents member
|
53
|
+
|
54
|
+
# Fetch office resource, allowing custom api_type to be passed
|
55
|
+
def offices(api_type: nil)
|
56
|
+
selected_api_type = api_type || @api_type
|
57
|
+
selected_api_type == :bridge ? Bridge::Office.new(@client, @server_token) : Reso::Office.new(@client, @server_token)
|
58
|
+
end
|
59
|
+
|
60
|
+
alias office offices
|
61
|
+
|
62
|
+
# Fetch open house resource, allowing custom api_type to be passed
|
63
|
+
def open_houses(api_type: nil)
|
64
|
+
selected_api_type = api_type || @api_type
|
65
|
+
selected_api_type == :bridge ? Bridge::OpenHouse.new(@client, @server_token) : Reso::OpenHouse.new(@client, @server_token)
|
66
|
+
end
|
67
|
+
|
68
|
+
alias open_house open_houses
|
69
|
+
|
70
|
+
# Fetch property resource, allowing custom api_type to be passed
|
71
|
+
def property(api_type: nil)
|
72
|
+
selected_api_type = api_type || @api_type
|
73
|
+
selected_api_type == :bridge ? Bridge::Listing.new(@client, @server_token) : Reso::Property.new(@client, @server_token)
|
74
|
+
end
|
75
|
+
|
76
|
+
alias listings property
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
# Log error and return false
|
81
|
+
def log_and_return_error(method_name, required_api)
|
82
|
+
message = "Error: '#{method_name}' can only be used with the #{required_api} API."
|
83
|
+
BridgeInteractive.configuration.logger.error(message) if BridgeInteractive.configuration.logger
|
84
|
+
raise StandardError, message
|
85
|
+
end
|
86
|
+
|
87
|
+
# Logging functionality (using the global logger, if provided)
|
88
|
+
def log(message)
|
89
|
+
BridgeInteractive.configuration.logger.info(message) if BridgeInteractive.configuration.logger
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Bridge
|
3
|
+
class Agent
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all agents from the specified dataset
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/agents"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch a specific agent by their agent ID
|
19
|
+
def find(dataset_id, agent_id)
|
20
|
+
endpoint = "#{BASE_URL}#{dataset_id}/agents/#{agent_id}"
|
21
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
22
|
+
handle_response(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Handle API response and parse the JSON response
|
28
|
+
def handle_response(response)
|
29
|
+
if response.status == 200
|
30
|
+
JSON.parse(response.body)
|
31
|
+
else
|
32
|
+
BridgeInteractive::Error.handle(response)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Bridge
|
3
|
+
class Dataset
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all datasets approved for the application
|
12
|
+
def all
|
13
|
+
endpoint = "#{BASE_URL}datasets"
|
14
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def handle_response(response)
|
21
|
+
if response.status == 200
|
22
|
+
JSON.parse(response.body)
|
23
|
+
else
|
24
|
+
BridgeInteractive::Error.handle(response)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Bridge
|
3
|
+
class Listing
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all listings from the specified dataset
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/listings"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch a specific listing by their listing ID
|
19
|
+
def find(dataset_id, listing_id)
|
20
|
+
endpoint = "#{BASE_URL}#{dataset_id}/listings/#{listing_id}"
|
21
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
22
|
+
handle_response(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Handle API response and parse the JSON response
|
28
|
+
def handle_response(response)
|
29
|
+
if response.status == 200
|
30
|
+
JSON.parse(response.body)
|
31
|
+
else
|
32
|
+
BridgeInteractive::Error.handle(response)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Bridge
|
3
|
+
class Office
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all offices from the specified dataset
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/offices"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch a specific office by their office ID
|
19
|
+
def find(dataset_id, office_id)
|
20
|
+
endpoint = "#{BASE_URL}#{dataset_id}/offices/#{office_id}"
|
21
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
22
|
+
handle_response(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Handle API response and parse the JSON response
|
28
|
+
def handle_response(response)
|
29
|
+
if response.status == 200
|
30
|
+
JSON.parse(response.body)
|
31
|
+
else
|
32
|
+
BridgeInteractive::Error.handle(response)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Bridge
|
3
|
+
class OpenHouse
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all open houses
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/openhouses"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch a specific open house by ID
|
19
|
+
def find(dataset_id, open_house_id)
|
20
|
+
endpoint = "#{BASE_URL}#{dataset_id}/openhouses/#{open_house_id}"
|
21
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
22
|
+
handle_response(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Handle API response and parse the JSON response
|
28
|
+
def handle_response(response)
|
29
|
+
if response.status == 200
|
30
|
+
JSON.parse(response.body)
|
31
|
+
else
|
32
|
+
BridgeInteractive::Error.handle(response)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
class Error
|
3
|
+
def self.handle(response)
|
4
|
+
begin
|
5
|
+
results = JSON.parse(response.body)
|
6
|
+
if results.key?("bundle")
|
7
|
+
message = "#{results['bundle']['name']}: #{results['bundle']['message']}"
|
8
|
+
elsif results.key?("error")
|
9
|
+
message = "Error #{results['error']['code']}: #{results['error']['message']}"
|
10
|
+
else
|
11
|
+
message = "Error not recognized: #{response.body}"
|
12
|
+
end
|
13
|
+
rescue => e
|
14
|
+
message = "Error: #{e.message}"
|
15
|
+
end
|
16
|
+
raise StandardError, message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Reso
|
3
|
+
class Lookup
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/OData/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch lookup data for a given dataset
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/Lookup"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Handle API response and parse the JSON response
|
21
|
+
def handle_response(response)
|
22
|
+
if response.status == 200
|
23
|
+
JSON.parse(response.body)
|
24
|
+
else
|
25
|
+
BridgeInteractive::Error.handle(response)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Reso
|
3
|
+
class Member
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/OData/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all members from the specified dataset
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/Member"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch a specific member by MemberKey
|
19
|
+
def find(dataset_id, member_key)
|
20
|
+
endpoint = "#{BASE_URL}#{dataset_id}/Member('#{member_key}')"
|
21
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
22
|
+
handle_response(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Handle API response and parse the JSON response
|
28
|
+
def handle_response(response)
|
29
|
+
if response.status == 200
|
30
|
+
JSON.parse(response.body)
|
31
|
+
else
|
32
|
+
BridgeInteractive::Error.handle(response)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Reso
|
3
|
+
class Office
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/OData/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all offices from the specified dataset
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/Offices"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch a specific office by their OfficeKey
|
19
|
+
def find(dataset_id, office_id)
|
20
|
+
endpoint = "#{BASE_URL}#{dataset_id}/Offices(#{office_id})"
|
21
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
22
|
+
handle_response(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Handle API response and parse the JSON response
|
28
|
+
def handle_response(response)
|
29
|
+
if response.status == 200
|
30
|
+
JSON.parse(response.body)
|
31
|
+
else
|
32
|
+
BridgeInteractive::Error.handle(response)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Reso
|
3
|
+
class OpenHouse
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/OData/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all open houses
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/OpenHouse"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch a specific open house by ID
|
19
|
+
def find(dataset_id, open_house_id)
|
20
|
+
# RESO uses a different format for IDs (surrounded by parentheses)
|
21
|
+
endpoint = "#{BASE_URL}#{dataset_id}/OpenHouse('#{open_house_id}')"
|
22
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
23
|
+
handle_response(response)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# Handle API response and parse the JSON response
|
29
|
+
def handle_response(response)
|
30
|
+
if response.status == 200
|
31
|
+
JSON.parse(response.body)
|
32
|
+
else
|
33
|
+
BridgeInteractive::Error.handle(response)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BridgeInteractive
|
2
|
+
module Reso
|
3
|
+
class Property
|
4
|
+
BASE_URL = 'https://api.bridgedataoutput.com/api/v2/OData/'
|
5
|
+
|
6
|
+
def initialize(client, server_token)
|
7
|
+
@client = client
|
8
|
+
@server_token = server_token
|
9
|
+
end
|
10
|
+
|
11
|
+
# Fetch all properties from the specified dataset
|
12
|
+
def all(dataset_id, filters = {})
|
13
|
+
endpoint = "#{BASE_URL}#{dataset_id}/Properties"
|
14
|
+
response = @client.get(endpoint, filters.merge(access_token: @server_token))
|
15
|
+
handle_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetch a specific property by their PropertyKey
|
19
|
+
def find(dataset_id, property_id)
|
20
|
+
endpoint = "#{BASE_URL}#{dataset_id}/Properties(#{property_id})"
|
21
|
+
response = @client.get(endpoint, { access_token: @server_token })
|
22
|
+
handle_response(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Handle API response and parse the JSON response
|
28
|
+
def handle_response(response)
|
29
|
+
if response.status == 200
|
30
|
+
JSON.parse(response.body)
|
31
|
+
else
|
32
|
+
BridgeInteractive::Error.handle(response)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'httpclient'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require_relative 'bridge_interactive/version'
|
5
|
+
require_relative 'bridge_interactive/configuration'
|
6
|
+
require_relative 'bridge_interactive/api'
|
7
|
+
require_relative 'bridge_interactive/error'
|
8
|
+
|
9
|
+
module BridgeInteractive
|
10
|
+
class << self
|
11
|
+
attr_accessor :configuration
|
12
|
+
|
13
|
+
# Automatically create a configuration object if it doesn't exist
|
14
|
+
def configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
17
|
+
|
18
|
+
# Create or yield the configuration block
|
19
|
+
def configure
|
20
|
+
yield(configuration)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Reset the configuration to default
|
24
|
+
def reset_configuration
|
25
|
+
@configuration = Configuration.new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bridge_interactive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stephen Higgins
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-10-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httpclient
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.8'
|
27
|
+
description: BridgeInteractive is a Ruby gem that provides a unified API client for
|
28
|
+
interacting with both the Bridge Web API and RESO Web API. It allows you to work
|
29
|
+
with datasets, properties, members, offices, and open houses from both systems using
|
30
|
+
a flexible configuration.
|
31
|
+
email:
|
32
|
+
- stephen@gryphonandrook.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- ".DS_Store"
|
38
|
+
- CHANGELOG.md
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/bridge_interactive.rb
|
43
|
+
- lib/bridge_interactive/.DS_Store
|
44
|
+
- lib/bridge_interactive/api.rb
|
45
|
+
- lib/bridge_interactive/bridge/agent.rb
|
46
|
+
- lib/bridge_interactive/bridge/dataset.rb
|
47
|
+
- lib/bridge_interactive/bridge/listing.rb
|
48
|
+
- lib/bridge_interactive/bridge/office.rb
|
49
|
+
- lib/bridge_interactive/bridge/open_house.rb
|
50
|
+
- lib/bridge_interactive/configuration.rb
|
51
|
+
- lib/bridge_interactive/error.rb
|
52
|
+
- lib/bridge_interactive/reso/.DS_Store
|
53
|
+
- lib/bridge_interactive/reso/lookup.rb
|
54
|
+
- lib/bridge_interactive/reso/member.rb
|
55
|
+
- lib/bridge_interactive/reso/office.rb
|
56
|
+
- lib/bridge_interactive/reso/open_house.rb
|
57
|
+
- lib/bridge_interactive/reso/property.rb
|
58
|
+
- lib/bridge_interactive/version.rb
|
59
|
+
- sig/bridge_interactive.rbs
|
60
|
+
homepage: https://github.com/gryphonandrook/bridge_interactive
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata:
|
64
|
+
allowed_push_host: https://rubygems.org
|
65
|
+
homepage_uri: https://github.com/gryphonandrook/bridge_interactive
|
66
|
+
source_code_uri: https://github.com/gryphonandrook/bridge_interactive
|
67
|
+
changelog_uri: https://github.com/gryphonandrook/bridge_interactive/CHANGELOG.md
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 3.0.0
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubygems_version: 3.4.19
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: BridgeInteractive is a Ruby gem that provides a unified API client for interacting
|
87
|
+
with both the Bridge Web API and RESO Web API.
|
88
|
+
test_files: []
|