Sha256: 03a2e58610243878fa31ad8d9d5aaba3a7a63b95e56c040b3888a601ff1e1d87

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

module Rexpense::Resources
  module Participant
    #
    # Get resource participants tags
    #
    # [API]
    #   Method: <tt>GET /api/v1/reimbursements/:id/participants</tt>
    #   Method: <tt>GET /api/v1/expenses/:id/participants</tt>
    #   Method: <tt>GET /api/v1/advancements/:id/participants</tt>
    #
    #   Documentation: http://developers.rexpense.com/api/participants#index
    #   Documentation: http://developers.rexpense.com/api/expense_participants#index
    #   Documentation: http://developers.rexpense.com/api/reimbursement_participants#index
    def participants(resource_id)
      http.get(participants_endpoint(resource_id)) do |response|
        Rexpense::Entities::UserCollection.build response
      end
    end

    #
    # Get resource participants tags
    #
    # [API]
    #   Method: <tt>GET /api/v1/reimbursements/:id/participants</tt>
    #   Method: <tt>GET /api/v1/expenses/:id/participants</tt>
    #   Method: <tt>GET /api/v1/advancements/:id/participants</tt>
    #
    #   Documentation: http://developers.rexpense.com/api/advancement_participants#destroy
    #   Documentation: http://developers.rexpense.com/api/expense_participants#destroy
    #   Documentation: http://developers.rexpense.com/api/reimbursement_participants#destroy
    def leave_participant(resource_id)
      http.delete(participants_endpoint(resource_id)) do |response|
        true
      end
    end

    private

    def participants_endpoint(resource_id)
      "#{endpoint_base}/#{resource_id}/participants"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rexpense-2.1.0 lib/rexpense/resources/nested_endpoints/participant.rb
rexpense-2.0.0 lib/rexpense/resources/nested_endpoints/participant.rb
rexpense-1.0.0 lib/rexpense/resources/nested_endpoints/participant.rb