Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/ioki/apis/operator_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ class OperatorApi
model_class: Ioki::Model::Operator::User,
except: [:update, :delete]
),
Endpoints::Create.new(
:eligibility_group_membership,
base_path: [API_BASE_PATH, 'providers', :id, 'eligibility_group_memberships'],
path: 'manually_assign_by_email_address',
model_class: Ioki::Model::Operator::EligibilityGroupMembership,
outgoing_model_class: Ioki::Model::Operator::EligibilityGroupMembershipManuallyAssignByEmailAddress,
method_name: 'eligibility_group_memberships_manually_assign_by_email_address'
),
Endpoints::ShowSingular.new(
:users_recently_used_stations,
base_path: nil,
Expand Down
45 changes: 45 additions & 0 deletions lib/ioki/model/operator/eligibility_group_membership.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

module Ioki
module Model
module Operator
class EligibilityGroupMembership < Base
attribute :id,
on: :read,
type: :string

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

attribute :created_at,
on: :read,
type: :date_time

attribute :updated_at,
on: :read,
type: :date_time

attribute :user_id,
on: :read,
type: :string

attribute :eligibility_group_slug,
on: :read,
type: :string

attribute :state,
on: :read,
type: :string

attribute :active_strategies,
on: :read,
type: :array

attribute :activated_at,
on: :read,
type: :date_time
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Ioki
module Model
module Operator
class EligibilityGroupMembershipManuallyAssignByEmailAddress < Base
attribute :email_address,
on: :create,
type: :string

attribute :user_segment_slug,
on: :create,
type: :string

attribute :eligibility_group_slug,
on: :create,
type: :string
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

RSpec.describe Ioki::Model::Operator::EligibilityGroupMembershipManuallyAssignByEmailAddress do
it { is_expected.to define_attribute(:email_address).as(:string) }
it { is_expected.to define_attribute(:user_segment_slug).as(:string) }
it { is_expected.to define_attribute(:eligibility_group_slug).as(:string) }
end
13 changes: 13 additions & 0 deletions spec/ioki/model/operator/eligibility_group_membership_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

RSpec.describe Ioki::Model::Operator::EligibilityGroupMembership do
it { is_expected.to define_attribute(:eligibility_group_slug).as(:string) }
it { is_expected.to define_attribute(:id).as(:string) }
it { is_expected.to define_attribute(:type).as(:string) }
it { is_expected.to define_attribute(:created_at).as(:date_time) }
it { is_expected.to define_attribute(:updated_at).as(:date_time) }
it { is_expected.to define_attribute(:user_id).as(:string) }
it { is_expected.to define_attribute(:state).as(:string) }
it { is_expected.to define_attribute(:active_strategies).as(:array) }
it { is_expected.to define_attribute(:activated_at).as(:date_time) }
end
27 changes: 27 additions & 0 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,33 @@
end
end

describe '#eligibility_group_memberships_manually_assign_by_email_address(provider_id, membership)' do
let(:membership) do
Ioki::Model::Operator::EligibilityGroupMembershipManuallyAssignByEmailAddress.new(
{
email_address: 'user@example.com',
user_segment_slug: 'example_user_segment',
eligibility_group_slug: 'example_eligibility_group'
}
)
end

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/providers/0815/eligibility_group_memberships/manually_assign_by_email_address')
expect(params[:method]).to eq(:post)
expect(params[:body]).to eq({ data: membership.serialize(:create, format: :json) })
[result_with_data, full_response]
end

expect(
operator_client.eligibility_group_memberships_manually_assign_by_email_address('0815', membership, options)
)
.to be_a(Ioki::Model::Operator::EligibilityGroupMembership)
end
end

describe '#create_ride_inquiry(product_id)' do
let(:ride_inquiry) { Ioki::Model::Operator::RideInquiry.new }

Expand Down