Skip to content

Commit

Permalink
Merge pull request #403 from ioki-mobility/refine-areas
Browse files Browse the repository at this point in the history
Operator Api | Refine `Area` model
  • Loading branch information
tom-ioki authored Jul 10, 2024
2 parents 4c21f0e + a753d31 commit f722623
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 20 deletions.
10 changes: 10 additions & 0 deletions lib/ioki/apis/operator_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ class OperatorApi
base_path: [API_BASE_PATH, 'products', :id],
model_class: Ioki::Model::Operator::Area
),
Endpoints::ShowSingular.new(
:drt_area,
base_path: [API_BASE_PATH, 'products', :id],
model_class: Ioki::Model::Operator::Area
),
Endpoints::ShowSingular.new(
:intermodal_area,
base_path: [API_BASE_PATH, 'products', :id],
model_class: Ioki::Model::Operator::Area
),
Endpoints.crud_endpoints(
:line,
base_path: [API_BASE_PATH, 'products', :id],
Expand Down
85 changes: 65 additions & 20 deletions lib/ioki/model/operator/area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,92 @@ class Area < Base
type: :date_time

attribute :name,
type: :string,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update]
omit_if_nil_on: [:create, :update],
type: :string

attribute :slug,
type: :string,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update]
omit_if_nil_on: [:create, :update],
type: :string

attribute :area_type,
type: :string,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update]
omit_if_nil_on: [:create, :update],
type: :string

attribute :description,
type: :string,
on: [:create, :read, :update]
on: [:create, :read, :update],
type: :string

attribute :color,
type: :string,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update]
omit_if_nil_on: [:create, :update],
type: :string

attribute :opacity,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :float

attribute :stroke_weight,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :integer

attribute :fill_color,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :fill_opacity,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :float

attribute :invert,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :boolean

attribute :z_index,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :integer

attribute :area,
attribute :legend_index,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :integer

attribute :legend_title,
on: :read,
type: :string

attribute :legend_description,
on: :read,
type: :string

attribute :legend_title_translations,
on: :read,
type: :object,
class_name: 'Geojson'
class_name: 'MultilanguageString'

attribute :inverted_area,
attribute :legend_description_translations,
on: :read,
type: :object,
class_name: 'Geojson'
class_name: 'MultilanguageString'

attribute :area_geojson,
on: [:create, :update],
type: :string
attribute :bounding_box,
on: :read,
type: :object,
class_name: 'BoundingBox'

attribute :product_id,
type: :string,
attribute :area_geojson,
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update]
omit_if_nil_on: [:create, :update],
type: :object,
class_name: 'Geojson'
end
end
end
Expand Down
24 changes: 24 additions & 0 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1609,4 +1609,28 @@
.to be_a(Ioki::Model::Operator::Zone)
end
end

describe '#drt_area(product_id)' do
it 'calls request on the client with expected params' do
expect(operator_client).to receive(:request) do |params|
expect(params[:url].to_s).to eq('operator/products/0815/drt_area')
[result_with_data, full_response]
end

expect(operator_client.drt_area('0815', options))
.to be_a(Ioki::Model::Operator::Area)
end
end

describe '#intermodal_area(product_id)' do
it 'calls request on the client with expected params' do
expect(operator_client).to receive(:request) do |params|
expect(params[:url].to_s).to eq('operator/products/0815/intermodal_area')
[result_with_data, full_response]
end

expect(operator_client.intermodal_area('0815', options))
.to be_a(Ioki::Model::Operator::Area)
end
end
end

0 comments on commit f722623

Please sign in to comment.