mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 09:30:03 +02:00
business registry contacts - endpoints for send status of contacts and receive confirmation
This commit is contained in:
parent
a393854e1a
commit
db012dd7da
7 changed files with 188 additions and 29 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@
|
||||||
/config/application.yml
|
/config/application.yml
|
||||||
/config/environments/development.rb
|
/config/environments/development.rb
|
||||||
/config/deploy.rb
|
/config/deploy.rb
|
||||||
|
/config/master.key
|
||||||
/.idea
|
/.idea
|
||||||
|
|
||||||
# Do not commit one. Instead, download the latest from https://github.com/internetee/style-guide.
|
# Do not commit one. Instead, download the latest from https://github.com/internetee/style-guide.
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
3.1.1
|
3.0.3
|
||||||
|
|
|
@ -34,6 +34,17 @@ module Api
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def do_need_update_contact
|
||||||
|
result = current_registrant_user.do_need_update_contact?
|
||||||
|
render json: { update_contacts: result[:result], counter: result[:counter] }
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_company_contacts
|
||||||
|
companies = current_registrant_user.update_company_contacts
|
||||||
|
|
||||||
|
render json: { message: 'get it', companies: companies }
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
logger.debug 'Received update request'
|
logger.debug 'Received update request'
|
||||||
logger.debug params
|
logger.debug params
|
||||||
|
|
|
@ -20,16 +20,34 @@ class RegistrantUser < User
|
||||||
def companies(company_register = CompanyRegister::Client.new)
|
def companies(company_register = CompanyRegister::Client.new)
|
||||||
return [] if ident.include?('-')
|
return [] if ident.include?('-')
|
||||||
|
|
||||||
companies = company_register.representation_rights(citizen_personal_code: ident,
|
company_register.representation_rights(citizen_personal_code: ident,
|
||||||
citizen_country_code: country.alpha3)
|
citizen_country_code: country.alpha3)
|
||||||
|
|
||||||
companies = update_contacts_before_receive(companies)
|
|
||||||
companies
|
|
||||||
rescue CompanyRegister::NotAvailableError
|
rescue CompanyRegister::NotAvailableError
|
||||||
return []
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_contacts_before_receive(companies)
|
def do_need_update_contact?
|
||||||
|
return { result: false, counter: 0 } if companies.blank?
|
||||||
|
|
||||||
|
counter = 0
|
||||||
|
companies.each do |company|
|
||||||
|
contacts = Contact.where(ident: company.registration_number, ident_country_code: 'EE')
|
||||||
|
|
||||||
|
next if contacts.blank?
|
||||||
|
|
||||||
|
contacts.each do |contact|
|
||||||
|
next if company.company_name == contact.name
|
||||||
|
|
||||||
|
counter += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return { result: true, counter: counter } if counter.positive?
|
||||||
|
|
||||||
|
{ result: false, counter: 0 }
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_company_contacts
|
||||||
return [] if companies.blank?
|
return [] if companies.blank?
|
||||||
|
|
||||||
companies.each do |company|
|
companies.each do |company|
|
||||||
|
|
|
@ -128,7 +128,10 @@ Rails.application.routes.draw do
|
||||||
resources :domains, only: %i[index show], param: :uuid do
|
resources :domains, only: %i[index show], param: :uuid do
|
||||||
resource :registry_lock, only: %i[create destroy]
|
resource :registry_lock, only: %i[create destroy]
|
||||||
end
|
end
|
||||||
resources :contacts, only: %i[index show update], param: :uuid
|
resources :contacts, only: %i[index show update], param: :uuid do
|
||||||
|
get 'do_need_update_contact', to: 'contacts#do_need_update_contact', as: :do_need_update_contact
|
||||||
|
post 'update_company_contacts', to: 'contacts#update_company_contacts', as: :update_company_contacts
|
||||||
|
end
|
||||||
resources :companies, only: %i[index]
|
resources :companies, only: %i[index]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
160
db/structure.sql
160
db/structure.sql
|
@ -51,6 +51,20 @@ CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
|
||||||
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
|
COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs';
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed';
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
|
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -202,6 +216,8 @@ CREATE FUNCTION public.generate_zonefile(i_origin character varying) RETURNS tex
|
||||||
|
|
||||||
SET default_tablespace = '';
|
SET default_tablespace = '';
|
||||||
|
|
||||||
|
SET default_with_oids = false;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: account_activities; Type: TABLE; Schema: public; Owner: -
|
-- Name: account_activities; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -809,7 +825,9 @@ CREATE TABLE public.dnskeys (
|
||||||
creator_str character varying,
|
creator_str character varying,
|
||||||
updator_str character varying,
|
updator_str character varying,
|
||||||
legacy_domain_id integer,
|
legacy_domain_id integer,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone,
|
||||||
|
validation_datetime timestamp without time zone,
|
||||||
|
failed_validation_reason character varying
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -936,6 +954,7 @@ CREATE TABLE public.domains (
|
||||||
pending_json jsonb,
|
pending_json jsonb,
|
||||||
force_delete_date date,
|
force_delete_date date,
|
||||||
statuses character varying[],
|
statuses character varying[],
|
||||||
|
status_notes public.hstore,
|
||||||
statuses_before_force_delete character varying[] DEFAULT '{}'::character varying[],
|
statuses_before_force_delete character varying[] DEFAULT '{}'::character varying[],
|
||||||
upid integer,
|
upid integer,
|
||||||
up_date timestamp without time zone,
|
up_date timestamp without time zone,
|
||||||
|
@ -943,8 +962,7 @@ CREATE TABLE public.domains (
|
||||||
locked_by_registrant_at timestamp without time zone,
|
locked_by_registrant_at timestamp without time zone,
|
||||||
force_delete_start timestamp without time zone,
|
force_delete_start timestamp without time zone,
|
||||||
force_delete_data public.hstore,
|
force_delete_data public.hstore,
|
||||||
json_statuses_history jsonb,
|
json_statuses_history jsonb
|
||||||
status_notes public.hstore
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1177,6 +1195,7 @@ CREATE TABLE public.invoices (
|
||||||
buyer_vat_no character varying,
|
buyer_vat_no character varying,
|
||||||
issue_date date NOT NULL,
|
issue_date date NOT NULL,
|
||||||
e_invoice_sent_at timestamp without time zone,
|
e_invoice_sent_at timestamp without time zone,
|
||||||
|
payment_link character varying,
|
||||||
CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date))
|
CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2263,6 +2282,74 @@ CREATE SEQUENCE public.payment_orders_id_seq
|
||||||
ALTER SEQUENCE public.payment_orders_id_seq OWNED BY public.payment_orders.id;
|
ALTER SEQUENCE public.payment_orders_id_seq OWNED BY public.payment_orders.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.pghero_query_stats (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
database text,
|
||||||
|
"user" text,
|
||||||
|
query text,
|
||||||
|
query_hash bigint,
|
||||||
|
total_time double precision,
|
||||||
|
calls bigint,
|
||||||
|
captured_at timestamp without time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.pghero_query_stats_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.pghero_query_stats_id_seq OWNED BY public.pghero_query_stats.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.pghero_space_stats (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
database text,
|
||||||
|
schema text,
|
||||||
|
relation text,
|
||||||
|
size bigint,
|
||||||
|
captured_at timestamp without time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.pghero_space_stats_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.pghero_space_stats_id_seq OWNED BY public.pghero_space_stats.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: prices; Type: TABLE; Schema: public; Owner: -
|
-- Name: prices; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -2623,8 +2710,7 @@ CREATE TABLE public.validation_events (
|
||||||
validation_eventable_type character varying,
|
validation_eventable_type character varying,
|
||||||
validation_eventable_id bigint,
|
validation_eventable_id bigint,
|
||||||
created_at timestamp(6) without time zone NOT NULL,
|
created_at timestamp(6) without time zone NOT NULL,
|
||||||
updated_at timestamp(6) without time zone NOT NULL,
|
updated_at timestamp(6) without time zone NOT NULL
|
||||||
event_type public.validation_type
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -3166,6 +3252,20 @@ ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('publi
|
||||||
ALTER TABLE ONLY public.payment_orders ALTER COLUMN id SET DEFAULT nextval('public.payment_orders_id_seq'::regclass);
|
ALTER TABLE ONLY public.payment_orders ALTER COLUMN id SET DEFAULT nextval('public.payment_orders_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.pghero_query_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_query_stats_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: prices id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: prices id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3689,6 +3789,22 @@ ALTER TABLE ONLY public.payment_orders
|
||||||
ADD CONSTRAINT payment_orders_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT payment_orders_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats pghero_query_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.pghero_query_stats
|
||||||
|
ADD CONSTRAINT pghero_query_stats_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats pghero_space_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.pghero_space_stats
|
||||||
|
ADD CONSTRAINT pghero_space_stats_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
-- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -4459,6 +4575,20 @@ CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING b
|
||||||
CREATE INDEX index_payment_orders_on_invoice_id ON public.payment_orders USING btree (invoice_id);
|
CREATE INDEX index_payment_orders_on_invoice_id ON public.payment_orders USING btree (invoice_id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_pghero_query_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX index_pghero_query_stats_on_database_and_captured_at ON public.pghero_query_stats USING btree (database, captured_at);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_pghero_space_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -4515,13 +4645,6 @@ CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_
|
||||||
CREATE INDEX index_validation_events_on_event_data ON public.validation_events USING gin (event_data);
|
CREATE INDEX index_validation_events_on_event_data ON public.validation_events USING gin (event_data);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_validation_events_on_event_type; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE INDEX index_validation_events_on_event_type ON public.validation_events USING btree (event_type);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_validation_events_on_validation_eventable; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_validation_events_on_validation_eventable; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -5267,15 +5390,20 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20210708131814'),
|
('20210708131814'),
|
||||||
('20210729131100'),
|
('20210729131100'),
|
||||||
('20210729134625'),
|
('20210729134625'),
|
||||||
('20210827185249'),
|
('20211028122103'),
|
||||||
('20211029073644'),
|
('20211028125245'),
|
||||||
|
('20211029082225'),
|
||||||
('20211124071418'),
|
('20211124071418'),
|
||||||
|
('20211124084308'),
|
||||||
('20211125181033'),
|
('20211125181033'),
|
||||||
('20211125184334'),
|
('20211125184334'),
|
||||||
('20211126085139'),
|
('20211126085139'),
|
||||||
|
('20211231113934'),
|
||||||
('20220106123143'),
|
('20220106123143'),
|
||||||
('20220113201642'),
|
('20220113201642'),
|
||||||
('20220113220809');
|
('20220113220809'),
|
||||||
|
('20220124105717'),
|
||||||
|
('20220216113112'),
|
||||||
|
('20220228093211');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,8 @@ class RegistrantUserTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
company = Company.new(org.ident, "ace")
|
company = Company.new(org.ident, "ace")
|
||||||
|
|
||||||
company_register = Minitest::Mock.new
|
Spy.on(@user, :companies).and_return([company])
|
||||||
company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234',
|
@user.update_company_contacts
|
||||||
citizen_country_code: 'USA' }])
|
|
||||||
@user.companies(company_register)
|
|
||||||
org.reload
|
org.reload
|
||||||
|
|
||||||
assert_equal org.name, company.company_name
|
assert_equal org.name, company.company_name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue