Module: ColoBiz::QueryMethod

Included in:
DataFetcher
Defined in:
lib/colo_biz/query_method.rb

Instance Method Summary collapse

Instance Method Details

#custom_query(query) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/colo_biz/query_method.rb', line 6

def custom_query(query)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?#{query}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_agent_full_name(first_name, last_name) ⇒ Object

first and last name are not case sensitive



85
86
87
88
89
90
91
# File 'lib/colo_biz/query_method.rb', line 85

def search_by_agent_full_name(first_name, last_name)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?agentfirstname=#{first_name}&agentlastname=#{last_name}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_agent_mailing_city(agent_mailing_country) ⇒ Object

skipped agent mailing addres 1 and 2



129
130
131
132
133
134
135
# File 'lib/colo_biz/query_method.rb', line 129

def search_by_agent_mailing_city(agent_mailing_city)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?agentmailingcity=#{agent_mailing_city}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_agent_mailing_state(agent_mailing_state) ⇒ Object



137
138
139
140
141
142
143
# File 'lib/colo_biz/query_method.rb', line 137

def search_by_agent_mailing_state(agent_mailing_state)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?agentmailingstate=#{agent_mailing_state}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_agent_mailing_zipcode(agent_mailing_zipcode) ⇒ Object



145
146
147
148
149
150
151
# File 'lib/colo_biz/query_method.rb', line 145

def search_by_agent_mailing_zipcode(agent_mailing_zipcode)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?agentmailingzipcode=#{agent_mailing_zipcode}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_agent_principal_city(agent_principal_city) ⇒ Object

skipped agent middle name, agent suffix, agent organization name, agent principle address 1 and 2



95
96
97
98
99
100
101
# File 'lib/colo_biz/query_method.rb', line 95

def search_by_agent_principal_city(agent_principal_city)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?agentprincipalcity=#{agent_principal_city}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_agent_principal_country(agent_principal_country) ⇒ Object



119
120
121
122
123
124
125
# File 'lib/colo_biz/query_method.rb', line 119

def search_by_agent_principal_country(agent_principal_country)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?agentprincipalcountry=#{agent_principal_country}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_agent_principal_state(agent_principal_state) ⇒ Object



103
104
105
106
107
108
109
# File 'lib/colo_biz/query_method.rb', line 103

def search_by_agent_principal_state(agent_principal_state)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?agentprincipalstate=#{agent_principal_state}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_agent_principal_zipcode(agent_principal_zipcode) ⇒ Object



111
112
113
114
115
116
117
# File 'lib/colo_biz/query_method.rb', line 111

def search_by_agent_principal_zipcode(agent_principal_zipcode)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?agentprincipalzipcode=#{agent_principal_zipcode}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_entity_name(entity_name) ⇒ Object

This query searches all names that contain the string entered. e.g. the argument ‘mill’ will return all the entities with mill in their name.



15
16
17
18
19
20
21
# File 'lib/colo_biz/query_method.rb', line 15

def search_by_entity_name(entity_name)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?$select=entityname&$q=#{entity_name}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_entity_status(entity_status) ⇒ Object

e.g. “Withdrawn”



57
58
59
60
61
62
63
# File 'lib/colo_biz/query_method.rb', line 57

def search_by_entity_status(entity_status)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?entitystatus=#{entity_status}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_entity_type(entity_type) ⇒ Object

Must be the acronym for the type. e.g. “WC” for water company



76
77
78
79
80
81
82
# File 'lib/colo_biz/query_method.rb', line 76

def search_by_entity_type(entity_type)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?entitytype=#{entity_type}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_entity_type_verbatum(entity_type_verbatum) ⇒ Object

e.g. “Water Company”



67
68
69
70
71
72
73
# File 'lib/colo_biz/query_method.rb', line 67

def search_by_entity_type_verbatum(entity_type_verbatum)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?entitytypeverbatum=#{entity_type_verbatum}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_principal_city(city_name) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/colo_biz/query_method.rb', line 23

def search_by_principal_city(city_name)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?principalcity=#{city_name}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_principal_country(two_letter_country_code) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/colo_biz/query_method.rb', line 47

def search_by_principal_country(two_letter_country_code)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?principalcountry=#{two_letter_country_code}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_principal_state(state_name) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/colo_biz/query_method.rb', line 31

def search_by_principal_state(state_name)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?principalstate=#{state_name}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_by_principal_zipcode(zipcode) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/colo_biz/query_method.rb', line 39

def search_by_principal_zipcode(zipcode)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?principalzipcode=#{zipcode}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_for_entities_(longitude, latitude, radius) ⇒ Object

radius is measured in miles



180
181
182
183
184
185
186
# File 'lib/colo_biz/query_method.rb', line 180

def search_for_entities_(longitude, latitude, radius)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?$where=within_circle(location, #{longitude}, #{latitude}, #{radius*1609})"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_for_entities_formed_before(date) ⇒ Object

must be in ‘YYYY-MM-DD’ format



171
172
173
174
175
176
177
# File 'lib/colo_biz/query_method.rb', line 171

def search_for_entities_formed_before(date)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?entityformdate < #{date}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end

#search_for_entity_formations_after(date) ⇒ Object

must be in ‘YYYY-MM-DD’ format



162
163
164
165
166
167
168
# File 'lib/colo_biz/query_method.rb', line 162

def search_for_entity_formations_after(date)
  response = @conn.get do |req|
    req.url "/resource/colorado-business-entities.json?entityformdate > #{date}"
  end
  parsed = JSON.parse(response.body)
  make_biz_entities(parsed)
end