├── LICENSE ├── ReadMe.md ├── api ├── number.go ├── profile.go └── send.go ├── build.sh ├── build_window.sh ├── gen ├── models │ ├── audio_message.go │ ├── broadcast_status.go │ ├── chat_item.go │ ├── contact_item.go │ ├── contact_message.go │ ├── doc_message.go │ ├── error.go │ ├── image_message.go │ ├── link_message.go │ ├── location_message.go │ ├── message_audio.go │ ├── message_battery.go │ ├── message_contact.go │ ├── message_context.go │ ├── message_doc.go │ ├── message_image.go │ ├── message_info.go │ ├── message_item.go │ ├── message_live_location.go │ ├── message_location.go │ ├── message_text.go │ ├── message_video.go │ ├── notify_connectivity.go │ ├── notify_logout.go │ ├── notify_receive.go │ ├── number_reply_ids.go │ ├── profile.go │ ├── q_r_code.go │ ├── read_ack.go │ ├── text_message.go │ ├── vcard_message.go │ └── video_message.go └── restapi │ ├── configure_wa.go │ ├── doc.go │ ├── embedded_spec.go │ ├── operations │ ├── hooks │ │ ├── post_message_audio.go │ │ ├── post_message_audio_parameters.go │ │ ├── post_message_audio_responses.go │ │ ├── post_message_audio_urlbuilder.go │ │ ├── post_message_contact.go │ │ ├── post_message_contact_parameters.go │ │ ├── post_message_contact_responses.go │ │ ├── post_message_contact_urlbuilder.go │ │ ├── post_message_doc.go │ │ ├── post_message_doc_parameters.go │ │ ├── post_message_doc_responses.go │ │ ├── post_message_doc_urlbuilder.go │ │ ├── post_message_image.go │ │ ├── post_message_image_parameters.go │ │ ├── post_message_image_responses.go │ │ ├── post_message_image_urlbuilder.go │ │ ├── post_message_livelocation.go │ │ ├── post_message_livelocation_parameters.go │ │ ├── post_message_livelocation_responses.go │ │ ├── post_message_livelocation_urlbuilder.go │ │ ├── post_message_location.go │ │ ├── post_message_location_parameters.go │ │ ├── post_message_location_responses.go │ │ ├── post_message_location_urlbuilder.go │ │ ├── post_message_text.go │ │ ├── post_message_text_parameters.go │ │ ├── post_message_text_responses.go │ │ ├── post_message_text_urlbuilder.go │ │ ├── post_message_video.go │ │ ├── post_message_video_parameters.go │ │ ├── post_message_video_responses.go │ │ ├── post_message_video_urlbuilder.go │ │ ├── post_notify_connectivity.go │ │ ├── post_notify_connectivity_parameters.go │ │ ├── post_notify_connectivity_responses.go │ │ ├── post_notify_connectivity_urlbuilder.go │ │ ├── post_notify_logout.go │ │ ├── post_notify_logout_parameters.go │ │ ├── post_notify_logout_responses.go │ │ ├── post_notify_logout_urlbuilder.go │ │ ├── post_notify_receive.go │ │ ├── post_notify_receive_parameters.go │ │ ├── post_notify_receive_responses.go │ │ ├── post_notify_receive_urlbuilder.go │ │ ├── post_power_battery.go │ │ ├── post_power_battery_parameters.go │ │ ├── post_power_battery_responses.go │ │ └── post_power_battery_urlbuilder.go │ ├── number │ │ ├── get_avatar.go │ │ ├── get_avatar_parameters.go │ │ ├── get_avatar_responses.go │ │ ├── get_avatar_urlbuilder.go │ │ ├── get_chats.go │ │ ├── get_chats_parameters.go │ │ ├── get_chats_responses.go │ │ ├── get_chats_urlbuilder.go │ │ ├── has_whats_app.go │ │ ├── has_whats_app_parameters.go │ │ ├── has_whats_app_responses.go │ │ ├── has_whats_app_urlbuilder.go │ │ ├── is_online.go │ │ ├── is_online_parameters.go │ │ ├── is_online_responses.go │ │ └── is_online_urlbuilder.go │ ├── profile │ │ ├── connect.go │ │ ├── connect_parameters.go │ │ ├── connect_responses.go │ │ ├── connect_urlbuilder.go │ │ ├── disconnect.go │ │ ├── disconnect_parameters.go │ │ ├── disconnect_responses.go │ │ ├── disconnect_urlbuilder.go │ │ ├── get_contacts.go │ │ ├── get_contacts_parameters.go │ │ ├── get_contacts_responses.go │ │ ├── get_contacts_urlbuilder.go │ │ ├── is_connected.go │ │ ├── is_connected_parameters.go │ │ ├── is_connected_responses.go │ │ ├── is_connected_urlbuilder.go │ │ ├── logout.go │ │ ├── logout_parameters.go │ │ ├── logout_responses.go │ │ ├── logout_urlbuilder.go │ │ ├── profile.go │ │ ├── profile_parameters.go │ │ ├── profile_responses.go │ │ ├── profile_urlbuilder.go │ │ ├── scan_qr.go │ │ ├── scan_qr_parameters.go │ │ ├── scan_qr_responses.go │ │ ├── scan_qr_urlbuilder.go │ │ ├── set_hook.go │ │ ├── set_hook_parameters.go │ │ ├── set_hook_responses.go │ │ └── set_hook_urlbuilder.go │ ├── send │ │ ├── send_audio.go │ │ ├── send_audio_parameters.go │ │ ├── send_audio_record.go │ │ ├── send_audio_record_parameters.go │ │ ├── send_audio_record_responses.go │ │ ├── send_audio_record_urlbuilder.go │ │ ├── send_audio_responses.go │ │ ├── send_audio_urlbuilder.go │ │ ├── send_doc.go │ │ ├── send_doc_parameters.go │ │ ├── send_doc_responses.go │ │ ├── send_doc_urlbuilder.go │ │ ├── send_image.go │ │ ├── send_image_parameters.go │ │ ├── send_image_responses.go │ │ ├── send_image_urlbuilder.go │ │ ├── send_link.go │ │ ├── send_link_parameters.go │ │ ├── send_link_responses.go │ │ ├── send_link_urlbuilder.go │ │ ├── send_location.go │ │ ├── send_location_parameters.go │ │ ├── send_location_responses.go │ │ ├── send_location_urlbuilder.go │ │ ├── send_read.go │ │ ├── send_read_parameters.go │ │ ├── send_read_responses.go │ │ ├── send_read_urlbuilder.go │ │ ├── send_text.go │ │ ├── send_text_parameters.go │ │ ├── send_text_responses.go │ │ ├── send_text_urlbuilder.go │ │ ├── send_vcard.go │ │ ├── send_vcard_parameters.go │ │ ├── send_vcard_responses.go │ │ ├── send_vcard_urlbuilder.go │ │ ├── send_video.go │ │ ├── send_video_parameters.go │ │ ├── send_video_responses.go │ │ └── send_video_urlbuilder.go │ └── wa_api.go │ └── server.go ├── generate.sh ├── go.mod ├── go.sum ├── main.go ├── static ├── favicon-16x16.png ├── favicon-32x32.png ├── index.html ├── oauth2-redirect.html ├── qrcode.zip ├── qrcode │ ├── README.mt │ ├── index.html │ └── scripts │ │ └── qrcode.js ├── spec.yml ├── swagger-ui-bundle.js ├── swagger-ui-bundle.js.map ├── swagger-ui-standalone-preset.js ├── swagger-ui-standalone-preset.js.map ├── swagger-ui.css ├── swagger-ui.css.map ├── swagger-ui.js ├── swagger-ui.js.map └── test-wa-handler-server.zip ├── storage ├── storage.go └── types.go ├── update └── whatsapp ├── handle_audio.go ├── handle_battery.go ├── handle_contact.go ├── handle_document.go ├── handle_error.go ├── handle_error.go.save ├── handle_image.go ├── handle_json.go ├── handle_live_location.go ├── handle_location.go ├── handle_new_contact.go ├── handle_text.go ├── handle_video.go ├── handler.go ├── history.go ├── main.go ├── message.go ├── queprocessor.go ├── send.go ├── send.go.save └── utils.go /build.sh: -------------------------------------------------------------------------------- 1 | env GOOS=linux GOARCH=386 go build -o wa-api -------------------------------------------------------------------------------- /build_window.sh: -------------------------------------------------------------------------------- 1 | env GOOS=windows GOARCH=386 go build -o wa-api -------------------------------------------------------------------------------- /gen/models/contact_item.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/errors" 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/swag" 12 | "github.com/go-openapi/validate" 13 | ) 14 | 15 | // ContactItem contact item 16 | // 17 | // swagger:model ContactItem 18 | type ContactItem struct { 19 | 20 | // Contact Name 21 | // Required: true 22 | Name *string `json:"name"` 23 | 24 | // Number with country code but without plus 25 | // Required: true 26 | Number *string `json:"number"` 27 | } 28 | 29 | // Validate validates this contact item 30 | func (m *ContactItem) Validate(formats strfmt.Registry) error { 31 | var res []error 32 | 33 | if err := m.validateName(formats); err != nil { 34 | res = append(res, err) 35 | } 36 | 37 | if err := m.validateNumber(formats); err != nil { 38 | res = append(res, err) 39 | } 40 | 41 | if len(res) > 0 { 42 | return errors.CompositeValidationError(res...) 43 | } 44 | return nil 45 | } 46 | 47 | func (m *ContactItem) validateName(formats strfmt.Registry) error { 48 | 49 | if err := validate.Required("name", "body", m.Name); err != nil { 50 | return err 51 | } 52 | 53 | return nil 54 | } 55 | 56 | func (m *ContactItem) validateNumber(formats strfmt.Registry) error { 57 | 58 | if err := validate.Required("number", "body", m.Number); err != nil { 59 | return err 60 | } 61 | 62 | return nil 63 | } 64 | 65 | // MarshalBinary interface implementation 66 | func (m *ContactItem) MarshalBinary() ([]byte, error) { 67 | if m == nil { 68 | return nil, nil 69 | } 70 | return swag.WriteJSON(m) 71 | } 72 | 73 | // UnmarshalBinary interface implementation 74 | func (m *ContactItem) UnmarshalBinary(b []byte) error { 75 | var res ContactItem 76 | if err := swag.ReadJSON(b, &res); err != nil { 77 | return err 78 | } 79 | *m = res 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /gen/models/error.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/errors" 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/swag" 12 | "github.com/go-openapi/validate" 13 | ) 14 | 15 | // Error error 16 | // 17 | // swagger:model Error 18 | type Error struct { 19 | 20 | // code 21 | Code int64 `json:"code,omitempty"` 22 | 23 | // message 24 | // Required: true 25 | Message *string `json:"message"` 26 | } 27 | 28 | // Validate validates this error 29 | func (m *Error) Validate(formats strfmt.Registry) error { 30 | var res []error 31 | 32 | if err := m.validateMessage(formats); err != nil { 33 | res = append(res, err) 34 | } 35 | 36 | if len(res) > 0 { 37 | return errors.CompositeValidationError(res...) 38 | } 39 | return nil 40 | } 41 | 42 | func (m *Error) validateMessage(formats strfmt.Registry) error { 43 | 44 | if err := validate.Required("message", "body", m.Message); err != nil { 45 | return err 46 | } 47 | 48 | return nil 49 | } 50 | 51 | // MarshalBinary interface implementation 52 | func (m *Error) MarshalBinary() ([]byte, error) { 53 | if m == nil { 54 | return nil, nil 55 | } 56 | return swag.WriteJSON(m) 57 | } 58 | 59 | // UnmarshalBinary interface implementation 60 | func (m *Error) UnmarshalBinary(b []byte) error { 61 | var res Error 62 | if err := swag.ReadJSON(b, &res); err != nil { 63 | return err 64 | } 65 | *m = res 66 | return nil 67 | } 68 | -------------------------------------------------------------------------------- /gen/models/message_context.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/errors" 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/swag" 12 | "github.com/go-openapi/validate" 13 | ) 14 | 15 | // MessageContext message context 16 | // 17 | // swagger:model MessageContext 18 | type MessageContext struct { 19 | 20 | // is forwarded 21 | // Required: true 22 | IsForwarded *bool `json:"isForwarded"` 23 | 24 | // participant 25 | Participant string `json:"participant,omitempty"` 26 | 27 | // product message currency code 28 | ProductMessageCurrencyCode string `json:"productMessageCurrencyCode,omitempty"` 29 | 30 | // product message description 31 | ProductMessageDescription string `json:"productMessageDescription,omitempty"` 32 | 33 | // product message Id 34 | ProductMessageID string `json:"productMessageId,omitempty"` 35 | 36 | // product message price 37 | ProductMessagePrice string `json:"productMessagePrice,omitempty"` 38 | 39 | // product message retailer Id 40 | ProductMessageRetailerID string `json:"productMessageRetailerId,omitempty"` 41 | 42 | // product message title 43 | ProductMessageTitle string `json:"productMessageTitle,omitempty"` 44 | 45 | // product message type 46 | ProductMessageType bool `json:"productMessageType,omitempty"` 47 | 48 | // product message Url 49 | ProductMessageURL string `json:"productMessageUrl,omitempty"` 50 | 51 | // quoted message Id 52 | QuotedMessageID string `json:"quotedMessageId,omitempty"` 53 | } 54 | 55 | // Validate validates this message context 56 | func (m *MessageContext) Validate(formats strfmt.Registry) error { 57 | var res []error 58 | 59 | if err := m.validateIsForwarded(formats); err != nil { 60 | res = append(res, err) 61 | } 62 | 63 | if len(res) > 0 { 64 | return errors.CompositeValidationError(res...) 65 | } 66 | return nil 67 | } 68 | 69 | func (m *MessageContext) validateIsForwarded(formats strfmt.Registry) error { 70 | 71 | if err := validate.Required("isForwarded", "body", m.IsForwarded); err != nil { 72 | return err 73 | } 74 | 75 | return nil 76 | } 77 | 78 | // MarshalBinary interface implementation 79 | func (m *MessageContext) MarshalBinary() ([]byte, error) { 80 | if m == nil { 81 | return nil, nil 82 | } 83 | return swag.WriteJSON(m) 84 | } 85 | 86 | // UnmarshalBinary interface implementation 87 | func (m *MessageContext) UnmarshalBinary(b []byte) error { 88 | var res MessageContext 89 | if err := swag.ReadJSON(b, &res); err != nil { 90 | return err 91 | } 92 | *m = res 93 | return nil 94 | } 95 | -------------------------------------------------------------------------------- /gen/models/message_item.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/errors" 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/swag" 12 | "github.com/go-openapi/validate" 13 | ) 14 | 15 | // MessageItem message item 16 | // 17 | // swagger:model MessageItem 18 | type MessageItem struct { 19 | 20 | // from me 21 | // Required: true 22 | FromMe *bool `json:"fromMe"` 23 | 24 | // id 25 | // Required: true 26 | ID *string `json:"id"` 27 | } 28 | 29 | // Validate validates this message item 30 | func (m *MessageItem) Validate(formats strfmt.Registry) error { 31 | var res []error 32 | 33 | if err := m.validateFromMe(formats); err != nil { 34 | res = append(res, err) 35 | } 36 | 37 | if err := m.validateID(formats); err != nil { 38 | res = append(res, err) 39 | } 40 | 41 | if len(res) > 0 { 42 | return errors.CompositeValidationError(res...) 43 | } 44 | return nil 45 | } 46 | 47 | func (m *MessageItem) validateFromMe(formats strfmt.Registry) error { 48 | 49 | if err := validate.Required("fromMe", "body", m.FromMe); err != nil { 50 | return err 51 | } 52 | 53 | return nil 54 | } 55 | 56 | func (m *MessageItem) validateID(formats strfmt.Registry) error { 57 | 58 | if err := validate.Required("id", "body", m.ID); err != nil { 59 | return err 60 | } 61 | 62 | return nil 63 | } 64 | 65 | // MarshalBinary interface implementation 66 | func (m *MessageItem) MarshalBinary() ([]byte, error) { 67 | if m == nil { 68 | return nil, nil 69 | } 70 | return swag.WriteJSON(m) 71 | } 72 | 73 | // UnmarshalBinary interface implementation 74 | func (m *MessageItem) UnmarshalBinary(b []byte) error { 75 | var res MessageItem 76 | if err := swag.ReadJSON(b, &res); err != nil { 77 | return err 78 | } 79 | *m = res 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /gen/models/number_reply_ids.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/errors" 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/swag" 12 | "github.com/go-openapi/validate" 13 | ) 14 | 15 | // NumberReplyIds number reply ids 16 | // 17 | // swagger:model NumberReplyIds 18 | type NumberReplyIds struct { 19 | 20 | // Number with country code but without plus 21 | // Required: true 22 | Number *string `json:"number"` 23 | 24 | // reply to 25 | ReplyTo *MessageItem `json:"replyTo,omitempty"` 26 | } 27 | 28 | // Validate validates this number reply ids 29 | func (m *NumberReplyIds) Validate(formats strfmt.Registry) error { 30 | var res []error 31 | 32 | if err := m.validateNumber(formats); err != nil { 33 | res = append(res, err) 34 | } 35 | 36 | if err := m.validateReplyTo(formats); err != nil { 37 | res = append(res, err) 38 | } 39 | 40 | if len(res) > 0 { 41 | return errors.CompositeValidationError(res...) 42 | } 43 | return nil 44 | } 45 | 46 | func (m *NumberReplyIds) validateNumber(formats strfmt.Registry) error { 47 | 48 | if err := validate.Required("number", "body", m.Number); err != nil { 49 | return err 50 | } 51 | 52 | return nil 53 | } 54 | 55 | func (m *NumberReplyIds) validateReplyTo(formats strfmt.Registry) error { 56 | 57 | if swag.IsZero(m.ReplyTo) { // not required 58 | return nil 59 | } 60 | 61 | if m.ReplyTo != nil { 62 | if err := m.ReplyTo.Validate(formats); err != nil { 63 | if ve, ok := err.(*errors.Validation); ok { 64 | return ve.ValidateName("replyTo") 65 | } 66 | return err 67 | } 68 | } 69 | 70 | return nil 71 | } 72 | 73 | // MarshalBinary interface implementation 74 | func (m *NumberReplyIds) MarshalBinary() ([]byte, error) { 75 | if m == nil { 76 | return nil, nil 77 | } 78 | return swag.WriteJSON(m) 79 | } 80 | 81 | // UnmarshalBinary interface implementation 82 | func (m *NumberReplyIds) UnmarshalBinary(b []byte) error { 83 | var res NumberReplyIds 84 | if err := swag.ReadJSON(b, &res); err != nil { 85 | return err 86 | } 87 | *m = res 88 | return nil 89 | } 90 | -------------------------------------------------------------------------------- /gen/models/profile.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/errors" 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/swag" 12 | "github.com/go-openapi/validate" 13 | ) 14 | 15 | // Profile profile 16 | // 17 | // swagger:model Profile 18 | type Profile struct { 19 | 20 | // phone number 21 | // Required: true 22 | PhoneNumber *string `json:"phoneNumber"` 23 | 24 | // profile pic 25 | // Format: uri 26 | ProfilePic strfmt.URI `json:"profilePic,omitempty"` 27 | } 28 | 29 | // Validate validates this profile 30 | func (m *Profile) Validate(formats strfmt.Registry) error { 31 | var res []error 32 | 33 | if err := m.validatePhoneNumber(formats); err != nil { 34 | res = append(res, err) 35 | } 36 | 37 | if err := m.validateProfilePic(formats); err != nil { 38 | res = append(res, err) 39 | } 40 | 41 | if len(res) > 0 { 42 | return errors.CompositeValidationError(res...) 43 | } 44 | return nil 45 | } 46 | 47 | func (m *Profile) validatePhoneNumber(formats strfmt.Registry) error { 48 | 49 | if err := validate.Required("phoneNumber", "body", m.PhoneNumber); err != nil { 50 | return err 51 | } 52 | 53 | return nil 54 | } 55 | 56 | func (m *Profile) validateProfilePic(formats strfmt.Registry) error { 57 | 58 | if swag.IsZero(m.ProfilePic) { // not required 59 | return nil 60 | } 61 | 62 | if err := validate.FormatOf("profilePic", "body", "uri", m.ProfilePic.String(), formats); err != nil { 63 | return err 64 | } 65 | 66 | return nil 67 | } 68 | 69 | // MarshalBinary interface implementation 70 | func (m *Profile) MarshalBinary() ([]byte, error) { 71 | if m == nil { 72 | return nil, nil 73 | } 74 | return swag.WriteJSON(m) 75 | } 76 | 77 | // UnmarshalBinary interface implementation 78 | func (m *Profile) UnmarshalBinary(b []byte) error { 79 | var res Profile 80 | if err := swag.ReadJSON(b, &res); err != nil { 81 | return err 82 | } 83 | *m = res 84 | return nil 85 | } 86 | -------------------------------------------------------------------------------- /gen/models/q_r_code.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/strfmt" 10 | "github.com/go-openapi/swag" 11 | ) 12 | 13 | // QRCode q r code 14 | // 15 | // swagger:model QRCode 16 | type QRCode struct { 17 | 18 | // base64 19 | Base64 string `json:"base64,omitempty"` 20 | } 21 | 22 | // Validate validates this q r code 23 | func (m *QRCode) Validate(formats strfmt.Registry) error { 24 | return nil 25 | } 26 | 27 | // MarshalBinary interface implementation 28 | func (m *QRCode) MarshalBinary() ([]byte, error) { 29 | if m == nil { 30 | return nil, nil 31 | } 32 | return swag.WriteJSON(m) 33 | } 34 | 35 | // UnmarshalBinary interface implementation 36 | func (m *QRCode) UnmarshalBinary(b []byte) error { 37 | var res QRCode 38 | if err := swag.ReadJSON(b, &res); err != nil { 39 | return err 40 | } 41 | *m = res 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /gen/models/read_ack.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package models 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "github.com/go-openapi/errors" 10 | "github.com/go-openapi/strfmt" 11 | "github.com/go-openapi/swag" 12 | "github.com/go-openapi/validate" 13 | ) 14 | 15 | // ReadAck read ack 16 | // 17 | // swagger:model ReadAck 18 | type ReadAck struct { 19 | 20 | // message Id 21 | // Required: true 22 | MessageID *string `json:"messageId"` 23 | 24 | // number 25 | // Required: true 26 | Number *string `json:"number"` 27 | 28 | // session Id 29 | // Required: true 30 | // Format: uuid4 31 | SessionID *strfmt.UUID4 `json:"sessionId"` 32 | } 33 | 34 | // Validate validates this read ack 35 | func (m *ReadAck) Validate(formats strfmt.Registry) error { 36 | var res []error 37 | 38 | if err := m.validateMessageID(formats); err != nil { 39 | res = append(res, err) 40 | } 41 | 42 | if err := m.validateNumber(formats); err != nil { 43 | res = append(res, err) 44 | } 45 | 46 | if err := m.validateSessionID(formats); err != nil { 47 | res = append(res, err) 48 | } 49 | 50 | if len(res) > 0 { 51 | return errors.CompositeValidationError(res...) 52 | } 53 | return nil 54 | } 55 | 56 | func (m *ReadAck) validateMessageID(formats strfmt.Registry) error { 57 | 58 | if err := validate.Required("messageId", "body", m.MessageID); err != nil { 59 | return err 60 | } 61 | 62 | return nil 63 | } 64 | 65 | func (m *ReadAck) validateNumber(formats strfmt.Registry) error { 66 | 67 | if err := validate.Required("number", "body", m.Number); err != nil { 68 | return err 69 | } 70 | 71 | return nil 72 | } 73 | 74 | func (m *ReadAck) validateSessionID(formats strfmt.Registry) error { 75 | 76 | if err := validate.Required("sessionId", "body", m.SessionID); err != nil { 77 | return err 78 | } 79 | 80 | if err := validate.FormatOf("sessionId", "body", "uuid4", m.SessionID.String(), formats); err != nil { 81 | return err 82 | } 83 | 84 | return nil 85 | } 86 | 87 | // MarshalBinary interface implementation 88 | func (m *ReadAck) MarshalBinary() ([]byte, error) { 89 | if m == nil { 90 | return nil, nil 91 | } 92 | return swag.WriteJSON(m) 93 | } 94 | 95 | // UnmarshalBinary interface implementation 96 | func (m *ReadAck) UnmarshalBinary(b []byte) error { 97 | var res ReadAck 98 | if err := swag.ReadJSON(b, &res); err != nil { 99 | return err 100 | } 101 | *m = res 102 | return nil 103 | } 104 | -------------------------------------------------------------------------------- /gen/restapi/doc.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | // Package restapi Wa-Api 4 | // 5 | // Whatsapp Rest API, you will need to scan the qr code using or your own front end or you could use this [ScanQR](/qrcode) link. 6 | // You can download the code [here](/qrcode.zip) 7 | // 8 | // To recieve message you will need to create your own server and set its url as hook using this [API](/#/Profile/setHook) as shown in hook [definitions](/#/Hooks). 9 | // You can download a sample nodejs server [here](/test-wa-handler-server.zip) 10 | // 11 | // PS: Phone numbers should have country code without the + sign eg: 14049190651 not +14049190651 12 | // Schemes: 13 | // http 14 | // Host: localhost 15 | // BasePath: /api 16 | // Version: 0.1.0 17 | // 18 | // Consumes: 19 | // - application/json 20 | // - multipart/form-data 21 | // - application/x-www-form-urlencoded 22 | // 23 | // Produces: 24 | // - application/json 25 | // 26 | // swagger:meta 27 | package restapi 28 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_audio.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostMessageAudioHandlerFunc turns a function with the right signature into a post message audio handler 15 | type PostMessageAudioHandlerFunc func(PostMessageAudioParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostMessageAudioHandlerFunc) Handle(params PostMessageAudioParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostMessageAudioHandler interface for that can handle valid post message audio params 23 | type PostMessageAudioHandler interface { 24 | Handle(PostMessageAudioParams) middleware.Responder 25 | } 26 | 27 | // NewPostMessageAudio creates a new http.Handler for the post message audio operation 28 | func NewPostMessageAudio(ctx *middleware.Context, handler PostMessageAudioHandler) *PostMessageAudio { 29 | return &PostMessageAudio{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostMessageAudio swagger:route POST /message/audio Hooks postMessageAudio 33 | 34 | Audio message hook 35 | 36 | */ 37 | type PostMessageAudio struct { 38 | Context *middleware.Context 39 | Handler PostMessageAudioHandler 40 | } 41 | 42 | func (o *PostMessageAudio) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostMessageAudioParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_audio_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostMessageAudioParams creates a new PostMessageAudioParams object 19 | // no default values defined in spec. 20 | func NewPostMessageAudioParams() PostMessageAudioParams { 21 | 22 | return PostMessageAudioParams{} 23 | } 24 | 25 | // PostMessageAudioParams contains all the bound params for the post message audio operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostMessageAudio 29 | type PostMessageAudioParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Audio message body 35 | In: body 36 | */ 37 | Data *models.MessageAudio 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostMessageAudioParams() beforehand. 44 | func (o *PostMessageAudioParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageAudio 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_audio_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostMessageAudioOKCode is the HTTP code returned for type PostMessageAudioOK 15 | const PostMessageAudioOKCode int = 200 16 | 17 | /*PostMessageAudioOK Return 200 else the api will retry 18 | 19 | swagger:response postMessageAudioOK 20 | */ 21 | type PostMessageAudioOK struct { 22 | } 23 | 24 | // NewPostMessageAudioOK creates PostMessageAudioOK with default headers values 25 | func NewPostMessageAudioOK() *PostMessageAudioOK { 26 | 27 | return &PostMessageAudioOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostMessageAudioOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_contact.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostMessageContactHandlerFunc turns a function with the right signature into a post message contact handler 15 | type PostMessageContactHandlerFunc func(PostMessageContactParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostMessageContactHandlerFunc) Handle(params PostMessageContactParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostMessageContactHandler interface for that can handle valid post message contact params 23 | type PostMessageContactHandler interface { 24 | Handle(PostMessageContactParams) middleware.Responder 25 | } 26 | 27 | // NewPostMessageContact creates a new http.Handler for the post message contact operation 28 | func NewPostMessageContact(ctx *middleware.Context, handler PostMessageContactHandler) *PostMessageContact { 29 | return &PostMessageContact{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostMessageContact swagger:route POST /message/contact Hooks postMessageContact 33 | 34 | Contact message hook 35 | 36 | */ 37 | type PostMessageContact struct { 38 | Context *middleware.Context 39 | Handler PostMessageContactHandler 40 | } 41 | 42 | func (o *PostMessageContact) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostMessageContactParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_contact_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostMessageContactParams creates a new PostMessageContactParams object 19 | // no default values defined in spec. 20 | func NewPostMessageContactParams() PostMessageContactParams { 21 | 22 | return PostMessageContactParams{} 23 | } 24 | 25 | // PostMessageContactParams contains all the bound params for the post message contact operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostMessageContact 29 | type PostMessageContactParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Contact message body 35 | In: body 36 | */ 37 | Data *models.MessageContact 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostMessageContactParams() beforehand. 44 | func (o *PostMessageContactParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageContact 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_contact_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostMessageContactOKCode is the HTTP code returned for type PostMessageContactOK 15 | const PostMessageContactOKCode int = 200 16 | 17 | /*PostMessageContactOK Return 200 else the api will retry 18 | 19 | swagger:response postMessageContactOK 20 | */ 21 | type PostMessageContactOK struct { 22 | } 23 | 24 | // NewPostMessageContactOK creates PostMessageContactOK with default headers values 25 | func NewPostMessageContactOK() *PostMessageContactOK { 26 | 27 | return &PostMessageContactOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostMessageContactOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_doc.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostMessageDocHandlerFunc turns a function with the right signature into a post message doc handler 15 | type PostMessageDocHandlerFunc func(PostMessageDocParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostMessageDocHandlerFunc) Handle(params PostMessageDocParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostMessageDocHandler interface for that can handle valid post message doc params 23 | type PostMessageDocHandler interface { 24 | Handle(PostMessageDocParams) middleware.Responder 25 | } 26 | 27 | // NewPostMessageDoc creates a new http.Handler for the post message doc operation 28 | func NewPostMessageDoc(ctx *middleware.Context, handler PostMessageDocHandler) *PostMessageDoc { 29 | return &PostMessageDoc{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostMessageDoc swagger:route POST /message/doc Hooks postMessageDoc 33 | 34 | Doc message hook 35 | 36 | */ 37 | type PostMessageDoc struct { 38 | Context *middleware.Context 39 | Handler PostMessageDocHandler 40 | } 41 | 42 | func (o *PostMessageDoc) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostMessageDocParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_doc_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostMessageDocParams creates a new PostMessageDocParams object 19 | // no default values defined in spec. 20 | func NewPostMessageDocParams() PostMessageDocParams { 21 | 22 | return PostMessageDocParams{} 23 | } 24 | 25 | // PostMessageDocParams contains all the bound params for the post message doc operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostMessageDoc 29 | type PostMessageDocParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Doc message body 35 | In: body 36 | */ 37 | Data *models.MessageDoc 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostMessageDocParams() beforehand. 44 | func (o *PostMessageDocParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageDoc 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_doc_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostMessageDocOKCode is the HTTP code returned for type PostMessageDocOK 15 | const PostMessageDocOKCode int = 200 16 | 17 | /*PostMessageDocOK Return 200 else the api will retry 18 | 19 | swagger:response postMessageDocOK 20 | */ 21 | type PostMessageDocOK struct { 22 | } 23 | 24 | // NewPostMessageDocOK creates PostMessageDocOK with default headers values 25 | func NewPostMessageDocOK() *PostMessageDocOK { 26 | 27 | return &PostMessageDocOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostMessageDocOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_doc_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // PostMessageDocURL generates an URL for the post message doc operation 15 | type PostMessageDocURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *PostMessageDocURL) WithBasePath(bp string) *PostMessageDocURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *PostMessageDocURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *PostMessageDocURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/message/doc" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *PostMessageDocURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *PostMessageDocURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *PostMessageDocURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on PostMessageDocURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on PostMessageDocURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *PostMessageDocURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_image.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostMessageImageHandlerFunc turns a function with the right signature into a post message image handler 15 | type PostMessageImageHandlerFunc func(PostMessageImageParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostMessageImageHandlerFunc) Handle(params PostMessageImageParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostMessageImageHandler interface for that can handle valid post message image params 23 | type PostMessageImageHandler interface { 24 | Handle(PostMessageImageParams) middleware.Responder 25 | } 26 | 27 | // NewPostMessageImage creates a new http.Handler for the post message image operation 28 | func NewPostMessageImage(ctx *middleware.Context, handler PostMessageImageHandler) *PostMessageImage { 29 | return &PostMessageImage{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostMessageImage swagger:route POST /message/image Hooks postMessageImage 33 | 34 | Image message hook 35 | 36 | */ 37 | type PostMessageImage struct { 38 | Context *middleware.Context 39 | Handler PostMessageImageHandler 40 | } 41 | 42 | func (o *PostMessageImage) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostMessageImageParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_image_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostMessageImageParams creates a new PostMessageImageParams object 19 | // no default values defined in spec. 20 | func NewPostMessageImageParams() PostMessageImageParams { 21 | 22 | return PostMessageImageParams{} 23 | } 24 | 25 | // PostMessageImageParams contains all the bound params for the post message image operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostMessageImage 29 | type PostMessageImageParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Image message body 35 | In: body 36 | */ 37 | Data *models.MessageImage 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostMessageImageParams() beforehand. 44 | func (o *PostMessageImageParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageImage 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_image_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostMessageImageOKCode is the HTTP code returned for type PostMessageImageOK 15 | const PostMessageImageOKCode int = 200 16 | 17 | /*PostMessageImageOK Return 200 else the api will retry 18 | 19 | swagger:response postMessageImageOK 20 | */ 21 | type PostMessageImageOK struct { 22 | } 23 | 24 | // NewPostMessageImageOK creates PostMessageImageOK with default headers values 25 | func NewPostMessageImageOK() *PostMessageImageOK { 26 | 27 | return &PostMessageImageOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostMessageImageOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_livelocation.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostMessageLivelocationHandlerFunc turns a function with the right signature into a post message livelocation handler 15 | type PostMessageLivelocationHandlerFunc func(PostMessageLivelocationParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostMessageLivelocationHandlerFunc) Handle(params PostMessageLivelocationParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostMessageLivelocationHandler interface for that can handle valid post message livelocation params 23 | type PostMessageLivelocationHandler interface { 24 | Handle(PostMessageLivelocationParams) middleware.Responder 25 | } 26 | 27 | // NewPostMessageLivelocation creates a new http.Handler for the post message livelocation operation 28 | func NewPostMessageLivelocation(ctx *middleware.Context, handler PostMessageLivelocationHandler) *PostMessageLivelocation { 29 | return &PostMessageLivelocation{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostMessageLivelocation swagger:route POST /message/livelocation Hooks postMessageLivelocation 33 | 34 | Live Location message hook 35 | 36 | */ 37 | type PostMessageLivelocation struct { 38 | Context *middleware.Context 39 | Handler PostMessageLivelocationHandler 40 | } 41 | 42 | func (o *PostMessageLivelocation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostMessageLivelocationParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_livelocation_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostMessageLivelocationParams creates a new PostMessageLivelocationParams object 19 | // no default values defined in spec. 20 | func NewPostMessageLivelocationParams() PostMessageLivelocationParams { 21 | 22 | return PostMessageLivelocationParams{} 23 | } 24 | 25 | // PostMessageLivelocationParams contains all the bound params for the post message livelocation operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostMessageLivelocation 29 | type PostMessageLivelocationParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Location message body 35 | In: body 36 | */ 37 | Data *models.MessageLiveLocation 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostMessageLivelocationParams() beforehand. 44 | func (o *PostMessageLivelocationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageLiveLocation 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_livelocation_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostMessageLivelocationOKCode is the HTTP code returned for type PostMessageLivelocationOK 15 | const PostMessageLivelocationOKCode int = 200 16 | 17 | /*PostMessageLivelocationOK Return 200 else the api will retry 18 | 19 | swagger:response postMessageLivelocationOK 20 | */ 21 | type PostMessageLivelocationOK struct { 22 | } 23 | 24 | // NewPostMessageLivelocationOK creates PostMessageLivelocationOK with default headers values 25 | func NewPostMessageLivelocationOK() *PostMessageLivelocationOK { 26 | 27 | return &PostMessageLivelocationOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostMessageLivelocationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_location.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostMessageLocationHandlerFunc turns a function with the right signature into a post message location handler 15 | type PostMessageLocationHandlerFunc func(PostMessageLocationParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostMessageLocationHandlerFunc) Handle(params PostMessageLocationParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostMessageLocationHandler interface for that can handle valid post message location params 23 | type PostMessageLocationHandler interface { 24 | Handle(PostMessageLocationParams) middleware.Responder 25 | } 26 | 27 | // NewPostMessageLocation creates a new http.Handler for the post message location operation 28 | func NewPostMessageLocation(ctx *middleware.Context, handler PostMessageLocationHandler) *PostMessageLocation { 29 | return &PostMessageLocation{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostMessageLocation swagger:route POST /message/location Hooks postMessageLocation 33 | 34 | Location message hook 35 | 36 | */ 37 | type PostMessageLocation struct { 38 | Context *middleware.Context 39 | Handler PostMessageLocationHandler 40 | } 41 | 42 | func (o *PostMessageLocation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostMessageLocationParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_location_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostMessageLocationParams creates a new PostMessageLocationParams object 19 | // no default values defined in spec. 20 | func NewPostMessageLocationParams() PostMessageLocationParams { 21 | 22 | return PostMessageLocationParams{} 23 | } 24 | 25 | // PostMessageLocationParams contains all the bound params for the post message location operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostMessageLocation 29 | type PostMessageLocationParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Location message body 35 | In: body 36 | */ 37 | Data *models.MessageLocation 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostMessageLocationParams() beforehand. 44 | func (o *PostMessageLocationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageLocation 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_location_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostMessageLocationOKCode is the HTTP code returned for type PostMessageLocationOK 15 | const PostMessageLocationOKCode int = 200 16 | 17 | /*PostMessageLocationOK Return 200 else the api will retry 18 | 19 | swagger:response postMessageLocationOK 20 | */ 21 | type PostMessageLocationOK struct { 22 | } 23 | 24 | // NewPostMessageLocationOK creates PostMessageLocationOK with default headers values 25 | func NewPostMessageLocationOK() *PostMessageLocationOK { 26 | 27 | return &PostMessageLocationOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostMessageLocationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_text.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostMessageTextHandlerFunc turns a function with the right signature into a post message text handler 15 | type PostMessageTextHandlerFunc func(PostMessageTextParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostMessageTextHandlerFunc) Handle(params PostMessageTextParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostMessageTextHandler interface for that can handle valid post message text params 23 | type PostMessageTextHandler interface { 24 | Handle(PostMessageTextParams) middleware.Responder 25 | } 26 | 27 | // NewPostMessageText creates a new http.Handler for the post message text operation 28 | func NewPostMessageText(ctx *middleware.Context, handler PostMessageTextHandler) *PostMessageText { 29 | return &PostMessageText{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostMessageText swagger:route POST /message/text Hooks postMessageText 33 | 34 | Text message hook 35 | 36 | */ 37 | type PostMessageText struct { 38 | Context *middleware.Context 39 | Handler PostMessageTextHandler 40 | } 41 | 42 | func (o *PostMessageText) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostMessageTextParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_text_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostMessageTextParams creates a new PostMessageTextParams object 19 | // no default values defined in spec. 20 | func NewPostMessageTextParams() PostMessageTextParams { 21 | 22 | return PostMessageTextParams{} 23 | } 24 | 25 | // PostMessageTextParams contains all the bound params for the post message text operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostMessageText 29 | type PostMessageTextParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Text message body 35 | In: body 36 | */ 37 | Data *models.MessageText 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostMessageTextParams() beforehand. 44 | func (o *PostMessageTextParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageText 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_text_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostMessageTextOKCode is the HTTP code returned for type PostMessageTextOK 15 | const PostMessageTextOKCode int = 200 16 | 17 | /*PostMessageTextOK Return 200 else the api will retry 18 | 19 | swagger:response postMessageTextOK 20 | */ 21 | type PostMessageTextOK struct { 22 | } 23 | 24 | // NewPostMessageTextOK creates PostMessageTextOK with default headers values 25 | func NewPostMessageTextOK() *PostMessageTextOK { 26 | 27 | return &PostMessageTextOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostMessageTextOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_text_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // PostMessageTextURL generates an URL for the post message text operation 15 | type PostMessageTextURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *PostMessageTextURL) WithBasePath(bp string) *PostMessageTextURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *PostMessageTextURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *PostMessageTextURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/message/text" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *PostMessageTextURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *PostMessageTextURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *PostMessageTextURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on PostMessageTextURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on PostMessageTextURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *PostMessageTextURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_video.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostMessageVideoHandlerFunc turns a function with the right signature into a post message video handler 15 | type PostMessageVideoHandlerFunc func(PostMessageVideoParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostMessageVideoHandlerFunc) Handle(params PostMessageVideoParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostMessageVideoHandler interface for that can handle valid post message video params 23 | type PostMessageVideoHandler interface { 24 | Handle(PostMessageVideoParams) middleware.Responder 25 | } 26 | 27 | // NewPostMessageVideo creates a new http.Handler for the post message video operation 28 | func NewPostMessageVideo(ctx *middleware.Context, handler PostMessageVideoHandler) *PostMessageVideo { 29 | return &PostMessageVideo{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostMessageVideo swagger:route POST /message/video Hooks postMessageVideo 33 | 34 | Video message hook 35 | 36 | */ 37 | type PostMessageVideo struct { 38 | Context *middleware.Context 39 | Handler PostMessageVideoHandler 40 | } 41 | 42 | func (o *PostMessageVideo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostMessageVideoParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_video_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostMessageVideoParams creates a new PostMessageVideoParams object 19 | // no default values defined in spec. 20 | func NewPostMessageVideoParams() PostMessageVideoParams { 21 | 22 | return PostMessageVideoParams{} 23 | } 24 | 25 | // PostMessageVideoParams contains all the bound params for the post message video operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostMessageVideo 29 | type PostMessageVideoParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Video message body 35 | In: body 36 | */ 37 | Data *models.MessageVideo 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostMessageVideoParams() beforehand. 44 | func (o *PostMessageVideoParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageVideo 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_message_video_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostMessageVideoOKCode is the HTTP code returned for type PostMessageVideoOK 15 | const PostMessageVideoOKCode int = 200 16 | 17 | /*PostMessageVideoOK Return 200 else the api will retry 18 | 19 | swagger:response postMessageVideoOK 20 | */ 21 | type PostMessageVideoOK struct { 22 | } 23 | 24 | // NewPostMessageVideoOK creates PostMessageVideoOK with default headers values 25 | func NewPostMessageVideoOK() *PostMessageVideoOK { 26 | 27 | return &PostMessageVideoOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostMessageVideoOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_connectivity.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostNotifyConnectivityHandlerFunc turns a function with the right signature into a post notify connectivity handler 15 | type PostNotifyConnectivityHandlerFunc func(PostNotifyConnectivityParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostNotifyConnectivityHandlerFunc) Handle(params PostNotifyConnectivityParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostNotifyConnectivityHandler interface for that can handle valid post notify connectivity params 23 | type PostNotifyConnectivityHandler interface { 24 | Handle(PostNotifyConnectivityParams) middleware.Responder 25 | } 26 | 27 | // NewPostNotifyConnectivity creates a new http.Handler for the post notify connectivity operation 28 | func NewPostNotifyConnectivity(ctx *middleware.Context, handler PostNotifyConnectivityHandler) *PostNotifyConnectivity { 29 | return &PostNotifyConnectivity{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostNotifyConnectivity swagger:route POST /notify/connectivity Hooks postNotifyConnectivity 33 | 34 | Notify when phone is not connected 35 | 36 | */ 37 | type PostNotifyConnectivity struct { 38 | Context *middleware.Context 39 | Handler PostNotifyConnectivityHandler 40 | } 41 | 42 | func (o *PostNotifyConnectivity) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostNotifyConnectivityParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_connectivity_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostNotifyConnectivityParams creates a new PostNotifyConnectivityParams object 19 | // no default values defined in spec. 20 | func NewPostNotifyConnectivityParams() PostNotifyConnectivityParams { 21 | 22 | return PostNotifyConnectivityParams{} 23 | } 24 | 25 | // PostNotifyConnectivityParams contains all the bound params for the post notify connectivity operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostNotifyConnectivity 29 | type PostNotifyConnectivityParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*when the user logs out 35 | In: body 36 | */ 37 | Data *models.NotifyConnectivity 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostNotifyConnectivityParams() beforehand. 44 | func (o *PostNotifyConnectivityParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.NotifyConnectivity 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_connectivity_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostNotifyConnectivityOKCode is the HTTP code returned for type PostNotifyConnectivityOK 15 | const PostNotifyConnectivityOKCode int = 200 16 | 17 | /*PostNotifyConnectivityOK Return 200 else the api will retry 18 | 19 | swagger:response postNotifyConnectivityOK 20 | */ 21 | type PostNotifyConnectivityOK struct { 22 | } 23 | 24 | // NewPostNotifyConnectivityOK creates PostNotifyConnectivityOK with default headers values 25 | func NewPostNotifyConnectivityOK() *PostNotifyConnectivityOK { 26 | 27 | return &PostNotifyConnectivityOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostNotifyConnectivityOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_logout.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostNotifyLogoutHandlerFunc turns a function with the right signature into a post notify logout handler 15 | type PostNotifyLogoutHandlerFunc func(PostNotifyLogoutParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostNotifyLogoutHandlerFunc) Handle(params PostNotifyLogoutParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostNotifyLogoutHandler interface for that can handle valid post notify logout params 23 | type PostNotifyLogoutHandler interface { 24 | Handle(PostNotifyLogoutParams) middleware.Responder 25 | } 26 | 27 | // NewPostNotifyLogout creates a new http.Handler for the post notify logout operation 28 | func NewPostNotifyLogout(ctx *middleware.Context, handler PostNotifyLogoutHandler) *PostNotifyLogout { 29 | return &PostNotifyLogout{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostNotifyLogout swagger:route POST /notify/logout Hooks postNotifyLogout 33 | 34 | Notify when user logs out 35 | 36 | */ 37 | type PostNotifyLogout struct { 38 | Context *middleware.Context 39 | Handler PostNotifyLogoutHandler 40 | } 41 | 42 | func (o *PostNotifyLogout) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostNotifyLogoutParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_logout_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostNotifyLogoutParams creates a new PostNotifyLogoutParams object 19 | // no default values defined in spec. 20 | func NewPostNotifyLogoutParams() PostNotifyLogoutParams { 21 | 22 | return PostNotifyLogoutParams{} 23 | } 24 | 25 | // PostNotifyLogoutParams contains all the bound params for the post notify logout operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostNotifyLogout 29 | type PostNotifyLogoutParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*when the user logs out 35 | In: body 36 | */ 37 | Data *models.NotifyLogout 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostNotifyLogoutParams() beforehand. 44 | func (o *PostNotifyLogoutParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.NotifyLogout 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_logout_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostNotifyLogoutOKCode is the HTTP code returned for type PostNotifyLogoutOK 15 | const PostNotifyLogoutOKCode int = 200 16 | 17 | /*PostNotifyLogoutOK Return 200 else the api will retry 18 | 19 | swagger:response postNotifyLogoutOK 20 | */ 21 | type PostNotifyLogoutOK struct { 22 | } 23 | 24 | // NewPostNotifyLogoutOK creates PostNotifyLogoutOK with default headers values 25 | func NewPostNotifyLogoutOK() *PostNotifyLogoutOK { 26 | 27 | return &PostNotifyLogoutOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostNotifyLogoutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_receive.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostNotifyReceiveHandlerFunc turns a function with the right signature into a post notify receive handler 15 | type PostNotifyReceiveHandlerFunc func(PostNotifyReceiveParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostNotifyReceiveHandlerFunc) Handle(params PostNotifyReceiveParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostNotifyReceiveHandler interface for that can handle valid post notify receive params 23 | type PostNotifyReceiveHandler interface { 24 | Handle(PostNotifyReceiveParams) middleware.Responder 25 | } 26 | 27 | // NewPostNotifyReceive creates a new http.Handler for the post notify receive operation 28 | func NewPostNotifyReceive(ctx *middleware.Context, handler PostNotifyReceiveHandler) *PostNotifyReceive { 29 | return &PostNotifyReceive{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostNotifyReceive swagger:route POST /notify/receive Hooks postNotifyReceive 33 | 34 | Notify when user receive the message 35 | 36 | */ 37 | type PostNotifyReceive struct { 38 | Context *middleware.Context 39 | Handler PostNotifyReceiveHandler 40 | } 41 | 42 | func (o *PostNotifyReceive) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostNotifyReceiveParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_receive_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostNotifyReceiveParams creates a new PostNotifyReceiveParams object 19 | // no default values defined in spec. 20 | func NewPostNotifyReceiveParams() PostNotifyReceiveParams { 21 | 22 | return PostNotifyReceiveParams{} 23 | } 24 | 25 | // PostNotifyReceiveParams contains all the bound params for the post notify receive operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostNotifyReceive 29 | type PostNotifyReceiveParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*when the user logs receive the message 35 | In: body 36 | */ 37 | Data *models.NotifyReceive 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostNotifyReceiveParams() beforehand. 44 | func (o *PostNotifyReceiveParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.NotifyReceive 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_notify_receive_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostNotifyReceiveOKCode is the HTTP code returned for type PostNotifyReceiveOK 15 | const PostNotifyReceiveOKCode int = 200 16 | 17 | /*PostNotifyReceiveOK Return 200 else the api will retry 18 | 19 | swagger:response postNotifyReceiveOK 20 | */ 21 | type PostNotifyReceiveOK struct { 22 | } 23 | 24 | // NewPostNotifyReceiveOK creates PostNotifyReceiveOK with default headers values 25 | func NewPostNotifyReceiveOK() *PostNotifyReceiveOK { 26 | 27 | return &PostNotifyReceiveOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostNotifyReceiveOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_power_battery.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // PostPowerBatteryHandlerFunc turns a function with the right signature into a post power battery handler 15 | type PostPowerBatteryHandlerFunc func(PostPowerBatteryParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn PostPowerBatteryHandlerFunc) Handle(params PostPowerBatteryParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // PostPowerBatteryHandler interface for that can handle valid post power battery params 23 | type PostPowerBatteryHandler interface { 24 | Handle(PostPowerBatteryParams) middleware.Responder 25 | } 26 | 27 | // NewPostPowerBattery creates a new http.Handler for the post power battery operation 28 | func NewPostPowerBattery(ctx *middleware.Context, handler PostPowerBatteryHandler) *PostPowerBattery { 29 | return &PostPowerBattery{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*PostPowerBattery swagger:route POST /power/battery Hooks postPowerBattery 33 | 34 | Contact message hook 35 | 36 | */ 37 | type PostPowerBattery struct { 38 | Context *middleware.Context 39 | Handler PostPowerBatteryHandler 40 | } 41 | 42 | func (o *PostPowerBattery) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewPostPowerBatteryParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_power_battery_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/errors" 12 | "github.com/go-openapi/runtime" 13 | "github.com/go-openapi/runtime/middleware" 14 | 15 | "bitbucket.org/rockyOO7/wa-api/gen/models" 16 | ) 17 | 18 | // NewPostPowerBatteryParams creates a new PostPowerBatteryParams object 19 | // no default values defined in spec. 20 | func NewPostPowerBatteryParams() PostPowerBatteryParams { 21 | 22 | return PostPowerBatteryParams{} 23 | } 24 | 25 | // PostPowerBatteryParams contains all the bound params for the post power battery operation 26 | // typically these are obtained from a http.Request 27 | // 28 | // swagger:parameters PostPowerBattery 29 | type PostPowerBatteryParams struct { 30 | 31 | // HTTP Request Object 32 | HTTPRequest *http.Request `json:"-"` 33 | 34 | /*Contact message body 35 | In: body 36 | */ 37 | Data *models.MessageBattery 38 | } 39 | 40 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 41 | // for simple values it will use straight method calls. 42 | // 43 | // To ensure default values, the struct must have been initialized with NewPostPowerBatteryParams() beforehand. 44 | func (o *PostPowerBatteryParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 45 | var res []error 46 | 47 | o.HTTPRequest = r 48 | 49 | if runtime.HasBody(r) { 50 | defer r.Body.Close() 51 | var body models.MessageBattery 52 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 53 | res = append(res, errors.NewParseError("data", "body", "", err)) 54 | } else { 55 | // validate body object 56 | if err := body.Validate(route.Formats); err != nil { 57 | res = append(res, err) 58 | } 59 | 60 | if len(res) == 0 { 61 | o.Data = &body 62 | } 63 | } 64 | } 65 | if len(res) > 0 { 66 | return errors.CompositeValidationError(res...) 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /gen/restapi/operations/hooks/post_power_battery_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | ) 13 | 14 | // PostPowerBatteryOKCode is the HTTP code returned for type PostPowerBatteryOK 15 | const PostPowerBatteryOKCode int = 200 16 | 17 | /*PostPowerBatteryOK Return 200 else the api will retry 18 | 19 | swagger:response postPowerBatteryOK 20 | */ 21 | type PostPowerBatteryOK struct { 22 | } 23 | 24 | // NewPostPowerBatteryOK creates PostPowerBatteryOK with default headers values 25 | func NewPostPowerBatteryOK() *PostPowerBatteryOK { 26 | 27 | return &PostPowerBatteryOK{} 28 | } 29 | 30 | // WriteResponse to the client 31 | func (o *PostPowerBatteryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 32 | 33 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 34 | 35 | rw.WriteHeader(200) 36 | } 37 | -------------------------------------------------------------------------------- /gen/restapi/operations/number/get_avatar.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package number 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // GetAvatarHandlerFunc turns a function with the right signature into a get avatar handler 15 | type GetAvatarHandlerFunc func(GetAvatarParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn GetAvatarHandlerFunc) Handle(params GetAvatarParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // GetAvatarHandler interface for that can handle valid get avatar params 23 | type GetAvatarHandler interface { 24 | Handle(GetAvatarParams) middleware.Responder 25 | } 26 | 27 | // NewGetAvatar creates a new http.Handler for the get avatar operation 28 | func NewGetAvatar(ctx *middleware.Context, handler GetAvatarHandler) *GetAvatar { 29 | return &GetAvatar{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*GetAvatar swagger:route GET /number/{phoneNumber}/avatar Number getAvatar 33 | 34 | GetAvatar get avatar API 35 | 36 | */ 37 | type GetAvatar struct { 38 | Context *middleware.Context 39 | Handler GetAvatarHandler 40 | } 41 | 42 | func (o *GetAvatar) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewGetAvatarParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/number/get_chats.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package number 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // GetChatsHandlerFunc turns a function with the right signature into a get chats handler 15 | type GetChatsHandlerFunc func(GetChatsParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn GetChatsHandlerFunc) Handle(params GetChatsParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // GetChatsHandler interface for that can handle valid get chats params 23 | type GetChatsHandler interface { 24 | Handle(GetChatsParams) middleware.Responder 25 | } 26 | 27 | // NewGetChats creates a new http.Handler for the get chats operation 28 | func NewGetChats(ctx *middleware.Context, handler GetChatsHandler) *GetChats { 29 | return &GetChats{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*GetChats swagger:route GET /number/{phoneNumber}/chats Number getChats 33 | 34 | Get chats for specific number 35 | 36 | */ 37 | type GetChats struct { 38 | Context *middleware.Context 39 | Handler GetChatsHandler 40 | } 41 | 42 | func (o *GetChats) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewGetChatsParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/connect.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // ConnectHandlerFunc turns a function with the right signature into a connect handler 15 | type ConnectHandlerFunc func(ConnectParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn ConnectHandlerFunc) Handle(params ConnectParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // ConnectHandler interface for that can handle valid connect params 23 | type ConnectHandler interface { 24 | Handle(ConnectParams) middleware.Responder 25 | } 26 | 27 | // NewConnect creates a new http.Handler for the connect operation 28 | func NewConnect(ctx *middleware.Context, handler ConnectHandler) *Connect { 29 | return &Connect{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*Connect swagger:route POST /profile/phone/connect Profile connect 33 | 34 | Connect using Session Id used while succesfull scan 35 | 36 | */ 37 | type Connect struct { 38 | Context *middleware.Context 39 | Handler ConnectHandler 40 | } 41 | 42 | func (o *Connect) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewConnectParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/connect_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "bitbucket.org/rockyOO7/wa-api/gen/models" 14 | ) 15 | 16 | // ConnectOKCode is the HTTP code returned for type ConnectOK 17 | const ConnectOKCode int = 200 18 | 19 | /*ConnectOK Ok 20 | 21 | swagger:response connectOK 22 | */ 23 | type ConnectOK struct { 24 | } 25 | 26 | // NewConnectOK creates ConnectOK with default headers values 27 | func NewConnectOK() *ConnectOK { 28 | 29 | return &ConnectOK{} 30 | } 31 | 32 | // WriteResponse to the client 33 | func (o *ConnectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 34 | 35 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 36 | 37 | rw.WriteHeader(200) 38 | } 39 | 40 | /*ConnectDefault Error Response 41 | 42 | swagger:response connectDefault 43 | */ 44 | type ConnectDefault struct { 45 | _statusCode int 46 | 47 | /* 48 | In: Body 49 | */ 50 | Payload *models.Error `json:"body,omitempty"` 51 | } 52 | 53 | // NewConnectDefault creates ConnectDefault with default headers values 54 | func NewConnectDefault(code int) *ConnectDefault { 55 | if code <= 0 { 56 | code = 500 57 | } 58 | 59 | return &ConnectDefault{ 60 | _statusCode: code, 61 | } 62 | } 63 | 64 | // WithStatusCode adds the status to the connect default response 65 | func (o *ConnectDefault) WithStatusCode(code int) *ConnectDefault { 66 | o._statusCode = code 67 | return o 68 | } 69 | 70 | // SetStatusCode sets the status to the connect default response 71 | func (o *ConnectDefault) SetStatusCode(code int) { 72 | o._statusCode = code 73 | } 74 | 75 | // WithPayload adds the payload to the connect default response 76 | func (o *ConnectDefault) WithPayload(payload *models.Error) *ConnectDefault { 77 | o.Payload = payload 78 | return o 79 | } 80 | 81 | // SetPayload sets the payload to the connect default response 82 | func (o *ConnectDefault) SetPayload(payload *models.Error) { 83 | o.Payload = payload 84 | } 85 | 86 | // WriteResponse to the client 87 | func (o *ConnectDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 88 | 89 | rw.WriteHeader(o._statusCode) 90 | if o.Payload != nil { 91 | payload := o.Payload 92 | if err := producer.Produce(rw, payload); err != nil { 93 | panic(err) // let the recovery middleware deal with this 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/connect_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // ConnectURL generates an URL for the connect operation 15 | type ConnectURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *ConnectURL) WithBasePath(bp string) *ConnectURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *ConnectURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *ConnectURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/profile/phone/connect" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *ConnectURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *ConnectURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *ConnectURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on ConnectURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on ConnectURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *ConnectURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/disconnect.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // DisconnectHandlerFunc turns a function with the right signature into a disconnect handler 15 | type DisconnectHandlerFunc func(DisconnectParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn DisconnectHandlerFunc) Handle(params DisconnectParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // DisconnectHandler interface for that can handle valid disconnect params 23 | type DisconnectHandler interface { 24 | Handle(DisconnectParams) middleware.Responder 25 | } 26 | 27 | // NewDisconnect creates a new http.Handler for the disconnect operation 28 | func NewDisconnect(ctx *middleware.Context, handler DisconnectHandler) *Disconnect { 29 | return &Disconnect{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*Disconnect swagger:route POST /profile/phone/disconnect Profile disconnect 33 | 34 | Disconnect Session Id used while succesfull scan 35 | 36 | */ 37 | type Disconnect struct { 38 | Context *middleware.Context 39 | Handler DisconnectHandler 40 | } 41 | 42 | func (o *Disconnect) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewDisconnectParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/disconnect_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "bitbucket.org/rockyOO7/wa-api/gen/models" 14 | ) 15 | 16 | // DisconnectOKCode is the HTTP code returned for type DisconnectOK 17 | const DisconnectOKCode int = 200 18 | 19 | /*DisconnectOK Ok 20 | 21 | swagger:response disconnectOK 22 | */ 23 | type DisconnectOK struct { 24 | } 25 | 26 | // NewDisconnectOK creates DisconnectOK with default headers values 27 | func NewDisconnectOK() *DisconnectOK { 28 | 29 | return &DisconnectOK{} 30 | } 31 | 32 | // WriteResponse to the client 33 | func (o *DisconnectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 34 | 35 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 36 | 37 | rw.WriteHeader(200) 38 | } 39 | 40 | /*DisconnectDefault Error Response 41 | 42 | swagger:response disconnectDefault 43 | */ 44 | type DisconnectDefault struct { 45 | _statusCode int 46 | 47 | /* 48 | In: Body 49 | */ 50 | Payload *models.Error `json:"body,omitempty"` 51 | } 52 | 53 | // NewDisconnectDefault creates DisconnectDefault with default headers values 54 | func NewDisconnectDefault(code int) *DisconnectDefault { 55 | if code <= 0 { 56 | code = 500 57 | } 58 | 59 | return &DisconnectDefault{ 60 | _statusCode: code, 61 | } 62 | } 63 | 64 | // WithStatusCode adds the status to the disconnect default response 65 | func (o *DisconnectDefault) WithStatusCode(code int) *DisconnectDefault { 66 | o._statusCode = code 67 | return o 68 | } 69 | 70 | // SetStatusCode sets the status to the disconnect default response 71 | func (o *DisconnectDefault) SetStatusCode(code int) { 72 | o._statusCode = code 73 | } 74 | 75 | // WithPayload adds the payload to the disconnect default response 76 | func (o *DisconnectDefault) WithPayload(payload *models.Error) *DisconnectDefault { 77 | o.Payload = payload 78 | return o 79 | } 80 | 81 | // SetPayload sets the payload to the disconnect default response 82 | func (o *DisconnectDefault) SetPayload(payload *models.Error) { 83 | o.Payload = payload 84 | } 85 | 86 | // WriteResponse to the client 87 | func (o *DisconnectDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 88 | 89 | rw.WriteHeader(o._statusCode) 90 | if o.Payload != nil { 91 | payload := o.Payload 92 | if err := producer.Produce(rw, payload); err != nil { 93 | panic(err) // let the recovery middleware deal with this 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/disconnect_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // DisconnectURL generates an URL for the disconnect operation 15 | type DisconnectURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *DisconnectURL) WithBasePath(bp string) *DisconnectURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *DisconnectURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *DisconnectURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/profile/phone/disconnect" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *DisconnectURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *DisconnectURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *DisconnectURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on DisconnectURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on DisconnectURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *DisconnectURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/get_contacts.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // GetContactsHandlerFunc turns a function with the right signature into a get contacts handler 15 | type GetContactsHandlerFunc func(GetContactsParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn GetContactsHandlerFunc) Handle(params GetContactsParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // GetContactsHandler interface for that can handle valid get contacts params 23 | type GetContactsHandler interface { 24 | Handle(GetContactsParams) middleware.Responder 25 | } 26 | 27 | // NewGetContacts creates a new http.Handler for the get contacts operation 28 | func NewGetContacts(ctx *middleware.Context, handler GetContactsHandler) *GetContacts { 29 | return &GetContacts{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*GetContacts swagger:route GET /profile/contacts Profile getContacts 33 | 34 | Get Contacts for the user 35 | 36 | */ 37 | type GetContacts struct { 38 | Context *middleware.Context 39 | Handler GetContactsHandler 40 | } 41 | 42 | func (o *GetContacts) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewGetContactsParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/logout.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // LogoutHandlerFunc turns a function with the right signature into a logout handler 15 | type LogoutHandlerFunc func(LogoutParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn LogoutHandlerFunc) Handle(params LogoutParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // LogoutHandler interface for that can handle valid logout params 23 | type LogoutHandler interface { 24 | Handle(LogoutParams) middleware.Responder 25 | } 26 | 27 | // NewLogout creates a new http.Handler for the logout operation 28 | func NewLogout(ctx *middleware.Context, handler LogoutHandler) *Logout { 29 | return &Logout{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*Logout swagger:route POST /profile/logout Profile logout 33 | 34 | The user will be logged out with his session cleared from DB, you will need to rescan and reset the webhook to reconnect the user 35 | 36 | */ 37 | type Logout struct { 38 | Context *middleware.Context 39 | Handler LogoutHandler 40 | } 41 | 42 | func (o *Logout) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewLogoutParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/logout_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "bitbucket.org/rockyOO7/wa-api/gen/models" 14 | ) 15 | 16 | // LogoutOKCode is the HTTP code returned for type LogoutOK 17 | const LogoutOKCode int = 200 18 | 19 | /*LogoutOK Ok 20 | 21 | swagger:response logoutOK 22 | */ 23 | type LogoutOK struct { 24 | } 25 | 26 | // NewLogoutOK creates LogoutOK with default headers values 27 | func NewLogoutOK() *LogoutOK { 28 | 29 | return &LogoutOK{} 30 | } 31 | 32 | // WriteResponse to the client 33 | func (o *LogoutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 34 | 35 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 36 | 37 | rw.WriteHeader(200) 38 | } 39 | 40 | /*LogoutDefault Error Response 41 | 42 | swagger:response logoutDefault 43 | */ 44 | type LogoutDefault struct { 45 | _statusCode int 46 | 47 | /* 48 | In: Body 49 | */ 50 | Payload *models.Error `json:"body,omitempty"` 51 | } 52 | 53 | // NewLogoutDefault creates LogoutDefault with default headers values 54 | func NewLogoutDefault(code int) *LogoutDefault { 55 | if code <= 0 { 56 | code = 500 57 | } 58 | 59 | return &LogoutDefault{ 60 | _statusCode: code, 61 | } 62 | } 63 | 64 | // WithStatusCode adds the status to the logout default response 65 | func (o *LogoutDefault) WithStatusCode(code int) *LogoutDefault { 66 | o._statusCode = code 67 | return o 68 | } 69 | 70 | // SetStatusCode sets the status to the logout default response 71 | func (o *LogoutDefault) SetStatusCode(code int) { 72 | o._statusCode = code 73 | } 74 | 75 | // WithPayload adds the payload to the logout default response 76 | func (o *LogoutDefault) WithPayload(payload *models.Error) *LogoutDefault { 77 | o.Payload = payload 78 | return o 79 | } 80 | 81 | // SetPayload sets the payload to the logout default response 82 | func (o *LogoutDefault) SetPayload(payload *models.Error) { 83 | o.Payload = payload 84 | } 85 | 86 | // WriteResponse to the client 87 | func (o *LogoutDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 88 | 89 | rw.WriteHeader(o._statusCode) 90 | if o.Payload != nil { 91 | payload := o.Payload 92 | if err := producer.Produce(rw, payload); err != nil { 93 | panic(err) // let the recovery middleware deal with this 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/logout_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // LogoutURL generates an URL for the logout operation 15 | type LogoutURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *LogoutURL) WithBasePath(bp string) *LogoutURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *LogoutURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *LogoutURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/profile/logout" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *LogoutURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *LogoutURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *LogoutURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on LogoutURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on LogoutURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *LogoutURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/profile.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // ProfileHandlerFunc turns a function with the right signature into a profile handler 15 | type ProfileHandlerFunc func(ProfileParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn ProfileHandlerFunc) Handle(params ProfileParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // ProfileHandler interface for that can handle valid profile params 23 | type ProfileHandler interface { 24 | Handle(ProfileParams) middleware.Responder 25 | } 26 | 27 | // NewProfile creates a new http.Handler for the profile operation 28 | func NewProfile(ctx *middleware.Context, handler ProfileHandler) *Profile { 29 | return &Profile{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*Profile swagger:route GET /profile/me Profile profile 33 | 34 | Get Scanned users profile pic and his phone number 35 | 36 | */ 37 | type Profile struct { 38 | Context *middleware.Context 39 | Handler ProfileHandler 40 | } 41 | 42 | func (o *Profile) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewProfileParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/scan_qr.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // ScanQrHandlerFunc turns a function with the right signature into a scan qr handler 15 | type ScanQrHandlerFunc func(ScanQrParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn ScanQrHandlerFunc) Handle(params ScanQrParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // ScanQrHandler interface for that can handle valid scan qr params 23 | type ScanQrHandler interface { 24 | Handle(ScanQrParams) middleware.Responder 25 | } 26 | 27 | // NewScanQr creates a new http.Handler for the scan qr operation 28 | func NewScanQr(ctx *middleware.Context, handler ScanQrHandler) *ScanQr { 29 | return &ScanQr{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*ScanQr swagger:route POST /profile/scanqr Profile scanQr 33 | 34 | Create a UUID4 identifier to use as sessionId. you will need to use this for every subsequent call, or use this [ScanQR](/qrcode) link 35 | 36 | */ 37 | type ScanQr struct { 38 | Context *middleware.Context 39 | Handler ScanQrHandler 40 | } 41 | 42 | func (o *ScanQr) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewScanQrParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/scan_qr_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // ScanQrURL generates an URL for the scan qr operation 15 | type ScanQrURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *ScanQrURL) WithBasePath(bp string) *ScanQrURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *ScanQrURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *ScanQrURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/profile/scanqr" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *ScanQrURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *ScanQrURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *ScanQrURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on ScanQrURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on ScanQrURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *ScanQrURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/set_hook.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SetHookHandlerFunc turns a function with the right signature into a set hook handler 15 | type SetHookHandlerFunc func(SetHookParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SetHookHandlerFunc) Handle(params SetHookParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SetHookHandler interface for that can handle valid set hook params 23 | type SetHookHandler interface { 24 | Handle(SetHookParams) middleware.Responder 25 | } 26 | 27 | // NewSetHook creates a new http.Handler for the set hook operation 28 | func NewSetHook(ctx *middleware.Context, handler SetHookHandler) *SetHook { 29 | return &SetHook{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SetHook swagger:route POST /profile/hook/set Profile setHook 33 | 34 | Set Hook for callbacks, refer hooks section for all hooks which will be called 35 | 36 | */ 37 | type SetHook struct { 38 | Context *middleware.Context 39 | Handler SetHookHandler 40 | } 41 | 42 | func (o *SetHook) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSetHookParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/set_hook_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "bitbucket.org/rockyOO7/wa-api/gen/models" 14 | ) 15 | 16 | // SetHookOKCode is the HTTP code returned for type SetHookOK 17 | const SetHookOKCode int = 200 18 | 19 | /*SetHookOK Ok 20 | 21 | swagger:response setHookOK 22 | */ 23 | type SetHookOK struct { 24 | } 25 | 26 | // NewSetHookOK creates SetHookOK with default headers values 27 | func NewSetHookOK() *SetHookOK { 28 | 29 | return &SetHookOK{} 30 | } 31 | 32 | // WriteResponse to the client 33 | func (o *SetHookOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 34 | 35 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 36 | 37 | rw.WriteHeader(200) 38 | } 39 | 40 | /*SetHookDefault Error Response 41 | 42 | swagger:response setHookDefault 43 | */ 44 | type SetHookDefault struct { 45 | _statusCode int 46 | 47 | /* 48 | In: Body 49 | */ 50 | Payload *models.Error `json:"body,omitempty"` 51 | } 52 | 53 | // NewSetHookDefault creates SetHookDefault with default headers values 54 | func NewSetHookDefault(code int) *SetHookDefault { 55 | if code <= 0 { 56 | code = 500 57 | } 58 | 59 | return &SetHookDefault{ 60 | _statusCode: code, 61 | } 62 | } 63 | 64 | // WithStatusCode adds the status to the set hook default response 65 | func (o *SetHookDefault) WithStatusCode(code int) *SetHookDefault { 66 | o._statusCode = code 67 | return o 68 | } 69 | 70 | // SetStatusCode sets the status to the set hook default response 71 | func (o *SetHookDefault) SetStatusCode(code int) { 72 | o._statusCode = code 73 | } 74 | 75 | // WithPayload adds the payload to the set hook default response 76 | func (o *SetHookDefault) WithPayload(payload *models.Error) *SetHookDefault { 77 | o.Payload = payload 78 | return o 79 | } 80 | 81 | // SetPayload sets the payload to the set hook default response 82 | func (o *SetHookDefault) SetPayload(payload *models.Error) { 83 | o.Payload = payload 84 | } 85 | 86 | // WriteResponse to the client 87 | func (o *SetHookDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 88 | 89 | rw.WriteHeader(o._statusCode) 90 | if o.Payload != nil { 91 | payload := o.Payload 92 | if err := producer.Produce(rw, payload); err != nil { 93 | panic(err) // let the recovery middleware deal with this 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /gen/restapi/operations/profile/set_hook_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package profile 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SetHookURL generates an URL for the set hook operation 15 | type SetHookURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SetHookURL) WithBasePath(bp string) *SetHookURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SetHookURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SetHookURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/profile/hook/set" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SetHookURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SetHookURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SetHookURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SetHookURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SetHookURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SetHookURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_audio.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendAudioHandlerFunc turns a function with the right signature into a send audio handler 15 | type SendAudioHandlerFunc func(SendAudioParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendAudioHandlerFunc) Handle(params SendAudioParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendAudioHandler interface for that can handle valid send audio params 23 | type SendAudioHandler interface { 24 | Handle(SendAudioParams) middleware.Responder 25 | } 26 | 27 | // NewSendAudio creates a new http.Handler for the send audio operation 28 | func NewSendAudio(ctx *middleware.Context, handler SendAudioHandler) *SendAudio { 29 | return &SendAudio{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendAudio swagger:route POST /send/audio Send sendAudio 33 | 34 | Send audio message 35 | 36 | */ 37 | type SendAudio struct { 38 | Context *middleware.Context 39 | Handler SendAudioHandler 40 | } 41 | 42 | func (o *SendAudio) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendAudioParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_audio_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendAudioParams creates a new SendAudioParams object 20 | // no default values defined in spec. 21 | func NewSendAudioParams() SendAudioParams { 22 | 23 | return SendAudioParams{} 24 | } 25 | 26 | // SendAudioParams contains all the bound params for the send audio operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters sendAudio 30 | type SendAudioParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.AudioMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendAudioParams() beforehand. 46 | func (o *SendAudioParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.AudioMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_audio_record.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendAudioRecordHandlerFunc turns a function with the right signature into a send audio record handler 15 | type SendAudioRecordHandlerFunc func(SendAudioRecordParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendAudioRecordHandlerFunc) Handle(params SendAudioRecordParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendAudioRecordHandler interface for that can handle valid send audio record params 23 | type SendAudioRecordHandler interface { 24 | Handle(SendAudioRecordParams) middleware.Responder 25 | } 26 | 27 | // NewSendAudioRecord creates a new http.Handler for the send audio record operation 28 | func NewSendAudioRecord(ctx *middleware.Context, handler SendAudioRecordHandler) *SendAudioRecord { 29 | return &SendAudioRecord{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendAudioRecord swagger:route POST /send/audiorecord Send sendAudioRecord 33 | 34 | Send audio record message 35 | 36 | */ 37 | type SendAudioRecord struct { 38 | Context *middleware.Context 39 | Handler SendAudioRecordHandler 40 | } 41 | 42 | func (o *SendAudioRecord) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendAudioRecordParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_audio_record_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendAudioRecordParams creates a new SendAudioRecordParams object 20 | // no default values defined in spec. 21 | func NewSendAudioRecordParams() SendAudioRecordParams { 22 | 23 | return SendAudioRecordParams{} 24 | } 25 | 26 | // SendAudioRecordParams contains all the bound params for the send audio record operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters sendAudioRecord 30 | type SendAudioRecordParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.AudioMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendAudioRecordParams() beforehand. 46 | func (o *SendAudioRecordParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.AudioMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_audio_record_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendAudioRecordURL generates an URL for the send audio record operation 15 | type SendAudioRecordURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendAudioRecordURL) WithBasePath(bp string) *SendAudioRecordURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendAudioRecordURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendAudioRecordURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/audiorecord" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendAudioRecordURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendAudioRecordURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendAudioRecordURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendAudioRecordURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendAudioRecordURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendAudioRecordURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_audio_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendAudioURL generates an URL for the send audio operation 15 | type SendAudioURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendAudioURL) WithBasePath(bp string) *SendAudioURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendAudioURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendAudioURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/audio" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendAudioURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendAudioURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendAudioURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendAudioURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendAudioURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendAudioURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_doc.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendDocHandlerFunc turns a function with the right signature into a send doc handler 15 | type SendDocHandlerFunc func(SendDocParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendDocHandlerFunc) Handle(params SendDocParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendDocHandler interface for that can handle valid send doc params 23 | type SendDocHandler interface { 24 | Handle(SendDocParams) middleware.Responder 25 | } 26 | 27 | // NewSendDoc creates a new http.Handler for the send doc operation 28 | func NewSendDoc(ctx *middleware.Context, handler SendDocHandler) *SendDoc { 29 | return &SendDoc{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendDoc swagger:route POST /send/doc Send sendDoc 33 | 34 | Send doc message 35 | 36 | */ 37 | type SendDoc struct { 38 | Context *middleware.Context 39 | Handler SendDocHandler 40 | } 41 | 42 | func (o *SendDoc) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendDocParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_doc_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendDocParams creates a new SendDocParams object 20 | // no default values defined in spec. 21 | func NewSendDocParams() SendDocParams { 22 | 23 | return SendDocParams{} 24 | } 25 | 26 | // SendDocParams contains all the bound params for the send doc operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters sendDoc 30 | type SendDocParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.DocMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendDocParams() beforehand. 46 | func (o *SendDocParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.DocMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_doc_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendDocURL generates an URL for the send doc operation 15 | type SendDocURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendDocURL) WithBasePath(bp string) *SendDocURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendDocURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendDocURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/doc" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendDocURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendDocURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendDocURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendDocURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendDocURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendDocURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_image.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendImageHandlerFunc turns a function with the right signature into a send image handler 15 | type SendImageHandlerFunc func(SendImageParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendImageHandlerFunc) Handle(params SendImageParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendImageHandler interface for that can handle valid send image params 23 | type SendImageHandler interface { 24 | Handle(SendImageParams) middleware.Responder 25 | } 26 | 27 | // NewSendImage creates a new http.Handler for the send image operation 28 | func NewSendImage(ctx *middleware.Context, handler SendImageHandler) *SendImage { 29 | return &SendImage{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendImage swagger:route POST /send/image Send sendImage 33 | 34 | Send Image Message 35 | 36 | */ 37 | type SendImage struct { 38 | Context *middleware.Context 39 | Handler SendImageHandler 40 | } 41 | 42 | func (o *SendImage) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendImageParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_image_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendImageParams creates a new SendImageParams object 20 | // no default values defined in spec. 21 | func NewSendImageParams() SendImageParams { 22 | 23 | return SendImageParams{} 24 | } 25 | 26 | // SendImageParams contains all the bound params for the send image operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters sendImage 30 | type SendImageParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.ImageMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendImageParams() beforehand. 46 | func (o *SendImageParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.ImageMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_image_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendImageURL generates an URL for the send image operation 15 | type SendImageURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendImageURL) WithBasePath(bp string) *SendImageURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendImageURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendImageURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/image" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendImageURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendImageURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendImageURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendImageURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendImageURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendImageURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_link.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendLinkHandlerFunc turns a function with the right signature into a send link handler 15 | type SendLinkHandlerFunc func(SendLinkParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendLinkHandlerFunc) Handle(params SendLinkParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendLinkHandler interface for that can handle valid send link params 23 | type SendLinkHandler interface { 24 | Handle(SendLinkParams) middleware.Responder 25 | } 26 | 27 | // NewSendLink creates a new http.Handler for the send link operation 28 | func NewSendLink(ctx *middleware.Context, handler SendLinkHandler) *SendLink { 29 | return &SendLink{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendLink swagger:route POST /send/link Send sendLink 33 | 34 | Send Link Preview 35 | 36 | */ 37 | type SendLink struct { 38 | Context *middleware.Context 39 | Handler SendLinkHandler 40 | } 41 | 42 | func (o *SendLink) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendLinkParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_link_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendLinkParams creates a new SendLinkParams object 20 | // no default values defined in spec. 21 | func NewSendLinkParams() SendLinkParams { 22 | 23 | return SendLinkParams{} 24 | } 25 | 26 | // SendLinkParams contains all the bound params for the send link operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters SendLink 30 | type SendLinkParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.LinkMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendLinkParams() beforehand. 46 | func (o *SendLinkParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.LinkMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_link_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendLinkURL generates an URL for the send link operation 15 | type SendLinkURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendLinkURL) WithBasePath(bp string) *SendLinkURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendLinkURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendLinkURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/link" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendLinkURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendLinkURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendLinkURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendLinkURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendLinkURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendLinkURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_location.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendLocationHandlerFunc turns a function with the right signature into a send location handler 15 | type SendLocationHandlerFunc func(SendLocationParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendLocationHandlerFunc) Handle(params SendLocationParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendLocationHandler interface for that can handle valid send location params 23 | type SendLocationHandler interface { 24 | Handle(SendLocationParams) middleware.Responder 25 | } 26 | 27 | // NewSendLocation creates a new http.Handler for the send location operation 28 | func NewSendLocation(ctx *middleware.Context, handler SendLocationHandler) *SendLocation { 29 | return &SendLocation{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendLocation swagger:route POST /send/location Send sendLocation 33 | 34 | Send location message 35 | 36 | */ 37 | type SendLocation struct { 38 | Context *middleware.Context 39 | Handler SendLocationHandler 40 | } 41 | 42 | func (o *SendLocation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendLocationParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_location_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendLocationParams creates a new SendLocationParams object 20 | // no default values defined in spec. 21 | func NewSendLocationParams() SendLocationParams { 22 | 23 | return SendLocationParams{} 24 | } 25 | 26 | // SendLocationParams contains all the bound params for the send location operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters sendLocation 30 | type SendLocationParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.LocationMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendLocationParams() beforehand. 46 | func (o *SendLocationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.LocationMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_location_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendLocationURL generates an URL for the send location operation 15 | type SendLocationURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendLocationURL) WithBasePath(bp string) *SendLocationURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendLocationURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendLocationURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/location" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendLocationURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendLocationURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendLocationURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendLocationURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendLocationURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendLocationURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_read.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendReadHandlerFunc turns a function with the right signature into a send read handler 15 | type SendReadHandlerFunc func(SendReadParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendReadHandlerFunc) Handle(params SendReadParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendReadHandler interface for that can handle valid send read params 23 | type SendReadHandler interface { 24 | Handle(SendReadParams) middleware.Responder 25 | } 26 | 27 | // NewSendRead creates a new http.Handler for the send read operation 28 | func NewSendRead(ctx *middleware.Context, handler SendReadHandler) *SendRead { 29 | return &SendRead{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendRead swagger:route POST /send/ack/read Send sendRead 33 | 34 | Send Read Reciept 35 | 36 | */ 37 | type SendRead struct { 38 | Context *middleware.Context 39 | Handler SendReadHandler 40 | } 41 | 42 | func (o *SendRead) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendReadParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_read_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendReadParams creates a new SendReadParams object 20 | // no default values defined in spec. 21 | func NewSendReadParams() SendReadParams { 22 | 23 | return SendReadParams{} 24 | } 25 | 26 | // SendReadParams contains all the bound params for the send read operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters sendRead 30 | type SendReadParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.ReadAck 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendReadParams() beforehand. 46 | func (o *SendReadParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.ReadAck 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_read_responses.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime" 12 | 13 | "bitbucket.org/rockyOO7/wa-api/gen/models" 14 | ) 15 | 16 | // SendReadOKCode is the HTTP code returned for type SendReadOK 17 | const SendReadOKCode int = 200 18 | 19 | /*SendReadOK Return chats for the specific 20 | 21 | swagger:response sendReadOK 22 | */ 23 | type SendReadOK struct { 24 | } 25 | 26 | // NewSendReadOK creates SendReadOK with default headers values 27 | func NewSendReadOK() *SendReadOK { 28 | 29 | return &SendReadOK{} 30 | } 31 | 32 | // WriteResponse to the client 33 | func (o *SendReadOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 34 | 35 | rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses 36 | 37 | rw.WriteHeader(200) 38 | } 39 | 40 | /*SendReadDefault Error Response 41 | 42 | swagger:response sendReadDefault 43 | */ 44 | type SendReadDefault struct { 45 | _statusCode int 46 | 47 | /* 48 | In: Body 49 | */ 50 | Payload *models.Error `json:"body,omitempty"` 51 | } 52 | 53 | // NewSendReadDefault creates SendReadDefault with default headers values 54 | func NewSendReadDefault(code int) *SendReadDefault { 55 | if code <= 0 { 56 | code = 500 57 | } 58 | 59 | return &SendReadDefault{ 60 | _statusCode: code, 61 | } 62 | } 63 | 64 | // WithStatusCode adds the status to the send read default response 65 | func (o *SendReadDefault) WithStatusCode(code int) *SendReadDefault { 66 | o._statusCode = code 67 | return o 68 | } 69 | 70 | // SetStatusCode sets the status to the send read default response 71 | func (o *SendReadDefault) SetStatusCode(code int) { 72 | o._statusCode = code 73 | } 74 | 75 | // WithPayload adds the payload to the send read default response 76 | func (o *SendReadDefault) WithPayload(payload *models.Error) *SendReadDefault { 77 | o.Payload = payload 78 | return o 79 | } 80 | 81 | // SetPayload sets the payload to the send read default response 82 | func (o *SendReadDefault) SetPayload(payload *models.Error) { 83 | o.Payload = payload 84 | } 85 | 86 | // WriteResponse to the client 87 | func (o *SendReadDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { 88 | 89 | rw.WriteHeader(o._statusCode) 90 | if o.Payload != nil { 91 | payload := o.Payload 92 | if err := producer.Produce(rw, payload); err != nil { 93 | panic(err) // let the recovery middleware deal with this 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_read_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendReadURL generates an URL for the send read operation 15 | type SendReadURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendReadURL) WithBasePath(bp string) *SendReadURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendReadURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendReadURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/ack/read" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendReadURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendReadURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendReadURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendReadURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendReadURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendReadURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_text.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendTextHandlerFunc turns a function with the right signature into a send text handler 15 | type SendTextHandlerFunc func(SendTextParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendTextHandlerFunc) Handle(params SendTextParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendTextHandler interface for that can handle valid send text params 23 | type SendTextHandler interface { 24 | Handle(SendTextParams) middleware.Responder 25 | } 26 | 27 | // NewSendText creates a new http.Handler for the send text operation 28 | func NewSendText(ctx *middleware.Context, handler SendTextHandler) *SendText { 29 | return &SendText{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendText swagger:route POST /send/text Send sendText 33 | 34 | Send text message 35 | 36 | */ 37 | type SendText struct { 38 | Context *middleware.Context 39 | Handler SendTextHandler 40 | } 41 | 42 | func (o *SendText) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendTextParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_text_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendTextParams creates a new SendTextParams object 20 | // no default values defined in spec. 21 | func NewSendTextParams() SendTextParams { 22 | 23 | return SendTextParams{} 24 | } 25 | 26 | // SendTextParams contains all the bound params for the send text operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters sendText 30 | type SendTextParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.TextMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendTextParams() beforehand. 46 | func (o *SendTextParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.TextMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_text_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendTextURL generates an URL for the send text operation 15 | type SendTextURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendTextURL) WithBasePath(bp string) *SendTextURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendTextURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendTextURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/text" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendTextURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendTextURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendTextURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendTextURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendTextURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendTextURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_vcard.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendVcardHandlerFunc turns a function with the right signature into a send vcard handler 15 | type SendVcardHandlerFunc func(SendVcardParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendVcardHandlerFunc) Handle(params SendVcardParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendVcardHandler interface for that can handle valid send vcard params 23 | type SendVcardHandler interface { 24 | Handle(SendVcardParams) middleware.Responder 25 | } 26 | 27 | // NewSendVcard creates a new http.Handler for the send vcard operation 28 | func NewSendVcard(ctx *middleware.Context, handler SendVcardHandler) *SendVcard { 29 | return &SendVcard{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendVcard swagger:route POST /send/vcard Send sendVcard 33 | 34 | Send SendVcard Document 35 | 36 | */ 37 | type SendVcard struct { 38 | Context *middleware.Context 39 | Handler SendVcardHandler 40 | } 41 | 42 | func (o *SendVcard) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendVcardParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_vcard_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendVcardParams creates a new SendVcardParams object 20 | // no default values defined in spec. 21 | func NewSendVcardParams() SendVcardParams { 22 | 23 | return SendVcardParams{} 24 | } 25 | 26 | // SendVcardParams contains all the bound params for the send vcard operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters SendVcard 30 | type SendVcardParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.ContactMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendVcardParams() beforehand. 46 | func (o *SendVcardParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.ContactMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_vcard_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendVcardURL generates an URL for the send vcard operation 15 | type SendVcardURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendVcardURL) WithBasePath(bp string) *SendVcardURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendVcardURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendVcardURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/vcard" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendVcardURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendVcardURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendVcardURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendVcardURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendVcardURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendVcardURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_video.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "net/http" 10 | 11 | "github.com/go-openapi/runtime/middleware" 12 | ) 13 | 14 | // SendVideoHandlerFunc turns a function with the right signature into a send video handler 15 | type SendVideoHandlerFunc func(SendVideoParams) middleware.Responder 16 | 17 | // Handle executing the request and returning a response 18 | func (fn SendVideoHandlerFunc) Handle(params SendVideoParams) middleware.Responder { 19 | return fn(params) 20 | } 21 | 22 | // SendVideoHandler interface for that can handle valid send video params 23 | type SendVideoHandler interface { 24 | Handle(SendVideoParams) middleware.Responder 25 | } 26 | 27 | // NewSendVideo creates a new http.Handler for the send video operation 28 | func NewSendVideo(ctx *middleware.Context, handler SendVideoHandler) *SendVideo { 29 | return &SendVideo{Context: ctx, Handler: handler} 30 | } 31 | 32 | /*SendVideo swagger:route POST /send/video Send sendVideo 33 | 34 | Send video message 35 | 36 | */ 37 | type SendVideo struct { 38 | Context *middleware.Context 39 | Handler SendVideoHandler 40 | } 41 | 42 | func (o *SendVideo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 43 | route, rCtx, _ := o.Context.RouteInfo(r) 44 | if rCtx != nil { 45 | r = rCtx 46 | } 47 | var Params = NewSendVideoParams() 48 | 49 | if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 50 | o.Context.Respond(rw, r, route.Produces, route, err) 51 | return 52 | } 53 | 54 | res := o.Handler.Handle(Params) // actually handle the request 55 | 56 | o.Context.Respond(rw, r, route.Produces, route, res) 57 | 58 | } 59 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_video_parameters.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the swagger generate command 7 | 8 | import ( 9 | "io" 10 | "net/http" 11 | 12 | "github.com/go-openapi/errors" 13 | "github.com/go-openapi/runtime" 14 | "github.com/go-openapi/runtime/middleware" 15 | 16 | "bitbucket.org/rockyOO7/wa-api/gen/models" 17 | ) 18 | 19 | // NewSendVideoParams creates a new SendVideoParams object 20 | // no default values defined in spec. 21 | func NewSendVideoParams() SendVideoParams { 22 | 23 | return SendVideoParams{} 24 | } 25 | 26 | // SendVideoParams contains all the bound params for the send video operation 27 | // typically these are obtained from a http.Request 28 | // 29 | // swagger:parameters sendVideo 30 | type SendVideoParams struct { 31 | 32 | // HTTP Request Object 33 | HTTPRequest *http.Request `json:"-"` 34 | 35 | /* 36 | Required: true 37 | In: body 38 | */ 39 | Data *models.VideoMessage 40 | } 41 | 42 | // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface 43 | // for simple values it will use straight method calls. 44 | // 45 | // To ensure default values, the struct must have been initialized with NewSendVideoParams() beforehand. 46 | func (o *SendVideoParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { 47 | var res []error 48 | 49 | o.HTTPRequest = r 50 | 51 | if runtime.HasBody(r) { 52 | defer r.Body.Close() 53 | var body models.VideoMessage 54 | if err := route.Consumer.Consume(r.Body, &body); err != nil { 55 | if err == io.EOF { 56 | res = append(res, errors.Required("data", "body", "")) 57 | } else { 58 | res = append(res, errors.NewParseError("data", "body", "", err)) 59 | } 60 | } else { 61 | // validate body object 62 | if err := body.Validate(route.Formats); err != nil { 63 | res = append(res, err) 64 | } 65 | 66 | if len(res) == 0 { 67 | o.Data = &body 68 | } 69 | } 70 | } else { 71 | res = append(res, errors.Required("data", "body", "")) 72 | } 73 | if len(res) > 0 { 74 | return errors.CompositeValidationError(res...) 75 | } 76 | return nil 77 | } 78 | -------------------------------------------------------------------------------- /gen/restapi/operations/send/send_video_urlbuilder.go: -------------------------------------------------------------------------------- 1 | // Code generated by go-swagger; DO NOT EDIT. 2 | 3 | package send 4 | 5 | // This file was generated by the swagger tool. 6 | // Editing this file might prove futile when you re-run the generate command 7 | 8 | import ( 9 | "errors" 10 | "net/url" 11 | golangswaggerpaths "path" 12 | ) 13 | 14 | // SendVideoURL generates an URL for the send video operation 15 | type SendVideoURL struct { 16 | _basePath string 17 | } 18 | 19 | // WithBasePath sets the base path for this url builder, only required when it's different from the 20 | // base path specified in the swagger spec. 21 | // When the value of the base path is an empty string 22 | func (o *SendVideoURL) WithBasePath(bp string) *SendVideoURL { 23 | o.SetBasePath(bp) 24 | return o 25 | } 26 | 27 | // SetBasePath sets the base path for this url builder, only required when it's different from the 28 | // base path specified in the swagger spec. 29 | // When the value of the base path is an empty string 30 | func (o *SendVideoURL) SetBasePath(bp string) { 31 | o._basePath = bp 32 | } 33 | 34 | // Build a url path and query string 35 | func (o *SendVideoURL) Build() (*url.URL, error) { 36 | var _result url.URL 37 | 38 | var _path = "/send/video" 39 | 40 | _basePath := o._basePath 41 | if _basePath == "" { 42 | _basePath = "/api" 43 | } 44 | _result.Path = golangswaggerpaths.Join(_basePath, _path) 45 | 46 | return &_result, nil 47 | } 48 | 49 | // Must is a helper function to panic when the url builder returns an error 50 | func (o *SendVideoURL) Must(u *url.URL, err error) *url.URL { 51 | if err != nil { 52 | panic(err) 53 | } 54 | if u == nil { 55 | panic("url can't be nil") 56 | } 57 | return u 58 | } 59 | 60 | // String returns the string representation of the path with query string 61 | func (o *SendVideoURL) String() string { 62 | return o.Must(o.Build()).String() 63 | } 64 | 65 | // BuildFull builds a full url with scheme, host, path and query string 66 | func (o *SendVideoURL) BuildFull(scheme, host string) (*url.URL, error) { 67 | if scheme == "" { 68 | return nil, errors.New("scheme is required for a full url on SendVideoURL") 69 | } 70 | if host == "" { 71 | return nil, errors.New("host is required for a full url on SendVideoURL") 72 | } 73 | 74 | base, err := o.Build() 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | base.Scheme = scheme 80 | base.Host = host 81 | return base, nil 82 | } 83 | 84 | // StringFull returns the string representation of a complete url 85 | func (o *SendVideoURL) StringFull(scheme, host string) string { 86 | return o.Must(o.BuildFull(scheme, host)).String() 87 | } 88 | -------------------------------------------------------------------------------- /generate.sh: -------------------------------------------------------------------------------- 1 | swagger generate server -t gen -f ./static/spec.yml --exclude-main -A wa-api -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module bitbucket.org/rockyOO7/wa-api 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/Rhymen/go-whatsapp v0.1.2-0.20210615184944-2b8a3e9b8aa2 7 | github.com/Rhymen/go-whatsapp/examples/echo v0.0.0-20190325075644-cc2581bbf24d // indirect 8 | github.com/Rhymen/go-whatsapp/examples/restoreSession v0.0.0-20190325075644-cc2581bbf24d // indirect 9 | github.com/Rhymen/go-whatsapp/examples/sendImage v0.0.0-20190325075644-cc2581bbf24d // indirect 10 | github.com/Rhymen/go-whatsapp/examples/sendTextMessages v0.0.0-20190325075644-cc2581bbf24d // indirect 11 | github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect 12 | github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e // indirect 13 | github.com/disintegration/imaging v1.6.2 14 | github.com/go-openapi/errors v0.19.7 15 | github.com/go-openapi/loads v0.19.5 16 | github.com/go-openapi/runtime v0.19.22 17 | github.com/go-openapi/spec v0.19.9 18 | github.com/go-openapi/strfmt v0.19.5 19 | github.com/go-openapi/swag v0.19.9 20 | github.com/go-openapi/validate v0.19.11 21 | github.com/go-swagger/go-swagger v0.24.0 // indirect 22 | github.com/golang/protobuf v1.4.3 // indirect 23 | github.com/google/uuid v1.1.2 24 | github.com/jessevdk/go-flags v1.4.0 25 | github.com/jinzhu/gorm v1.9.16 26 | github.com/jinzhu/now v1.1.1 // indirect 27 | github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect 28 | github.com/lib/pq v1.3.0 // indirect 29 | github.com/mailru/easyjson v0.7.6 // indirect 30 | github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect 31 | github.com/mitchellh/mapstructure v1.3.3 // indirect 32 | github.com/rs/cors v1.7.0 33 | github.com/sirupsen/logrus v1.7.0 34 | go.mongodb.org/mongo-driver v1.4.1 // indirect 35 | golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect 36 | golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 // indirect 37 | golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 38 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect 39 | google.golang.org/protobuf v1.25.0 // indirect 40 | ) 41 | -------------------------------------------------------------------------------- /static/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beshoo/go-whatsapp-rest-api/42e8a6571e5cc256ea721fc9da7ccaae34c4328b/static/favicon-16x16.png -------------------------------------------------------------------------------- /static/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beshoo/go-whatsapp-rest-api/42e8a6571e5cc256ea721fc9da7ccaae34c4328b/static/favicon-32x32.png -------------------------------------------------------------------------------- /static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Swagger UI 7 | 8 | 14 | 20 | 38 | 39 | 40 | 41 |
42 | 43 | 44 | 45 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /static/oauth2-redirect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Swagger UI: OAuth2 Redirect 4 | 5 | 6 | 7 | 69 | -------------------------------------------------------------------------------- /static/qrcode.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beshoo/go-whatsapp-rest-api/42e8a6571e5cc256ea721fc9da7ccaae34c4328b/static/qrcode.zip -------------------------------------------------------------------------------- /static/qrcode/README.mt: -------------------------------------------------------------------------------- 1 | Please update [SERVER_IP_ADDRESS] in the **index.html** with your domian or your public server Ip Address 2 | -------------------------------------------------------------------------------- /static/qrcode/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
Session ID
7 |
8 |
QR Code to scan
9 |
10 |
======== Profile =========
11 |
12 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /static/test-wa-handler-server.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beshoo/go-whatsapp-rest-api/42e8a6571e5cc256ea721fc9da7ccaae34c4328b/static/test-wa-handler-server.zip -------------------------------------------------------------------------------- /storage/types.go: -------------------------------------------------------------------------------- 1 | package storage 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/jinzhu/gorm" 7 | ) 8 | 9 | // 10 | type WASession struct { 11 | ID string 12 | ClientID string 13 | ClientToken string 14 | ServerToken string 15 | EncKey string 16 | MacKey string 17 | Wid string 18 | HookURL *string 19 | ProxyURL *string 20 | CreatedAt time.Time 21 | UpdatedAt time.Time 22 | DeletedAt *time.Time 23 | } 24 | 25 | 26 | 27 | 28 | 29 | // 30 | type BroadcastStatus string 31 | 32 | // 33 | const ( 34 | COMPLETED BroadcastStatus = "COMPLETED" 35 | ONGOING BroadcastStatus = "ONGOING" 36 | STOPPED BroadcastStatus = "STOPPED" 37 | ) 38 | 39 | // 40 | type WABroadcast struct { 41 | ID string 42 | Status BroadcastStatus 43 | MediaType MediaType 44 | Messages []WAMessage 45 | CreatedAt time.Time 46 | UpdatedAt time.Time 47 | DeletedAt *time.Time 48 | } 49 | 50 | // 51 | type MessageStatus string 52 | 53 | // 54 | const ( 55 | ERR MessageStatus = "ERROR" 56 | SENT MessageStatus = "SENT" 57 | RECIEVED MessageStatus = "RECIEVED" 58 | READ MessageStatus = "READ" 59 | INCOM MessageStatus = "INCOMING" 60 | HOOKED MessageStatus = "HOOKED" 61 | ) 62 | 63 | // 64 | type Direction string 65 | 66 | // 67 | const ( 68 | INCOMING Direction = "INCOMING" 69 | OUTGOING Direction = "OUTGOING" 70 | ) 71 | 72 | // 73 | type MediaType string 74 | 75 | // 76 | const ( 77 | TEXT MediaType = "TEXT" 78 | VIDEO MediaType = "VIDEO" 79 | IMAGE MediaType = "IMAGE" 80 | VCARD MediaType = "VCARD" 81 | LINK MediaType = "LINK" 82 | DOC MediaType = "DOC" 83 | AUDIO MediaType = "AUDIO" 84 | CONTACT MediaType = "CONTACT" 85 | LOC MediaType = "LOC" 86 | LIVELOC MediaType = "LIVE_LOC" 87 | ) 88 | 89 | // 90 | type WAMessage struct { 91 | gorm.Model 92 | WhatsappID string 93 | BroadcastID *string 94 | From string 95 | To string 96 | Status MessageStatus 97 | Direction Direction 98 | MediaType MediaType 99 | SentAt *time.Time 100 | RecievedAt *time.Time 101 | ReadAt *time.Time 102 | IncomingAt *time.Time 103 | HookedAt *time.Time 104 | } 105 | -------------------------------------------------------------------------------- /update: -------------------------------------------------------------------------------- 1 | go get github.com/Rhymen/go-whatsapp@master 2 | -------------------------------------------------------------------------------- /whatsapp/handle_battery.go: -------------------------------------------------------------------------------- 1 | package whatsapp 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "time" 8 | // "strings" 9 | "bitbucket.org/rockyOO7/wa-api/gen/models" 10 | "github.com/go-openapi/strfmt" 11 | wa "github.com/Rhymen/go-whatsapp" 12 | log "github.com/sirupsen/logrus" 13 | ) 14 | 15 | // 16 | func (wh *WaHandler) HandleBatteryMessage(message wa.BatteryMessage) { 17 | 18 | 19 | // fmt.Printf("%#v", message) 20 | if wh.Hook == nil { 21 | log.Warnf("No hook specified for %v", wh.Wac.Info.Wid) 22 | return 23 | } 24 | 25 | sessionID := strfmt.UUID4(*wh.SessionID) 26 | number := NumberFromWidJid(wh.Wac.Info.Wid) 27 | percent := int64(message.Percentage) 28 | contactMessage := models.MessageBattery{ 29 | SessionID: &sessionID, 30 | Number: &number, 31 | Plugged: &message.Plugged, 32 | Powersave: &message.Powersave, 33 | Percentage: &percent, 34 | } 35 | 36 | messageBytes, err := json.Marshal(contactMessage) 37 | if err != nil { 38 | log.Errorf("Request Json Marshal failed with error %v", err) 39 | return 40 | } 41 | 42 | err = Retry(retrySend, time.Millisecond*500, func() error { 43 | return requestWith(fmt.Sprintf("%v/power/battery", *wh.Hook), "application/json", bytes.NewReader(messageBytes)) 44 | }) 45 | 46 | if err != nil { 47 | log.Errorf("Contact Request Failed with error %v", err) 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /whatsapp/handle_contact.go: -------------------------------------------------------------------------------- 1 | package whatsapp 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "time" 8 | "strings" 9 | "bitbucket.org/rockyOO7/wa-api/gen/models" 10 | "bitbucket.org/rockyOO7/wa-api/storage" 11 | wa "github.com/Rhymen/go-whatsapp" 12 | log "github.com/sirupsen/logrus" 13 | ) 14 | //var StartTime = uint64(time.Now().Unix()) 15 | // 16 | func (wh *WaHandler) HandleContactMessage(message wa.ContactMessage) { 17 | 18 | if message.Info.Timestamp < StartTime { 19 | return 20 | } 21 | 22 | if strings.Contains(message.Info.RemoteJid, "@g.us") { 23 | return 24 | } 25 | 26 | if message.Info.FromMe { 27 | return 28 | } 29 | 30 | if uint64(time.Now().Unix()) > message.Info.Timestamp { 31 | receiveTimeDef := uint64(time.Now().Unix()) - message.Info.Timestamp 32 | 33 | if receiveTimeDef > allowTimeDef { 34 | log.Infof("Old MessageID %v %v",wh.Wac.Info.Wid ,message.Info.Id) 35 | return 36 | } 37 | } 38 | 39 | 40 | from := NumberFromWidJid(message.Info.RemoteJid) 41 | to := NumberFromWidJid(wh.Wac.Info.Wid) 42 | if from == "status" || to == "status" { 43 | return 44 | } 45 | if storage.MessageExist(message.Info.Id, storage.INCOMING) { 46 | return 47 | } 48 | now := time.Now() 49 | storage.CreateMessage(storage.WAMessage{ 50 | WhatsappID: message.Info.Id, 51 | From: NumberFromWidJid(message.Info.RemoteJid), 52 | To: NumberFromWidJid(wh.Wac.Info.Wid), 53 | Status: storage.INCOM, 54 | Direction: storage.INCOMING, 55 | MediaType: storage.CONTACT, 56 | IncomingAt: &now, 57 | }) 58 | 59 | if wh.Hook == nil { 60 | log.Warnf("No hook specified for %v", wh.Wac.Info.Wid) 61 | return 62 | } 63 | 64 | messageInfo := wh.messageInfo(message.Info) 65 | messageContext := wh.context(message.ContextInfo) 66 | 67 | contactMessage := models.MessageContact{ 68 | ContextInfo: &messageContext, 69 | MessageInfo: &messageInfo, 70 | DisplayName: message.DisplayName, 71 | Vcard: message.Vcard, 72 | } 73 | 74 | messageBytes, err := json.Marshal(contactMessage) 75 | if err != nil { 76 | log.Errorf("Video Request Json Marshal failed with error %v", err) 77 | return 78 | } 79 | 80 | err = Retry(retrySend, time.Millisecond*500, func() error { 81 | return requestWith(fmt.Sprintf("%v/message/contact", *wh.Hook), "application/json", bytes.NewReader(messageBytes)) 82 | }) 83 | if err != nil { 84 | log.Errorf("Contact Request Failed with error %v", err) 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /whatsapp/handle_json.go: -------------------------------------------------------------------------------- 1 | package whatsapp 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | // "time" 7 | "bitbucket.org/rockyOO7/wa-api/storage" 8 | log "github.com/sirupsen/logrus" 9 | ) 10 | 11 | // 12 | func (wh *WaHandler) HandleJsonMessage(message string) { 13 | var msg []interface{} 14 | err := json.Unmarshal([]byte(message), &msg) 15 | if err != nil { 16 | log.Errorf("json parsing error %v", err) 17 | return 18 | } 19 | // log.Info(message) 20 | if msg[0] == "Stream" { 21 | if msg[1] == "asleep" { 22 | go wh.NotifyConnectivity(false) 23 | wh.SendSignal(PAUSE) 24 | 25 | } 26 | } 27 | if msg[0] == "Conn" { 28 | go wh.NotifyConnectivity(true) 29 | wh.SendSignal(RESUME) 30 | } 31 | if msg[0] == "Presence" { 32 | updates := msg[1].(map[string]interface{}) 33 | number := NumberFromWidJid(fmt.Sprintf("%v", updates["id"])) 34 | isOnline := false 35 | lastSeen := fmt.Sprintf("%v", updates["t"]) 36 | available := fmt.Sprintf("%v", updates["type"]) 37 | if available == "available" { 38 | isOnline = true 39 | } 40 | wh.numberOnline(number, isOnline, lastSeen) 41 | 42 | } 43 | 44 | if msg[0] == "Cmd" { 45 | jsonres := msg[1].(map[string]interface{}) 46 | if jsonres["type"] == "disconnect" { 47 | wh.reloginCounter(wh.Wac.Info.Wid , 1) 48 | // go wh.NotifyConnectivity(false) 49 | // wh.SendSignal(PAUSE) 50 | if value, ok := jsonres["kind"]; ok { 51 | if value == "replaced" { 52 | 53 | log.Info("Kind replace") 54 | go wh.NotifyDisconnect(wh.Wac.Info.Wid) 55 | }else{ 56 | 57 | log.Infof("Json connection not handeld var %v",value) 58 | 59 | } 60 | 61 | } else { 62 | log.Info("Json Logout") 63 | wh.logout() 64 | go wh.NotifyLogout(wh.Wac.Info.Wid) 65 | 66 | } 67 | } 68 | } 69 | 70 | 71 | 72 | if msg[0] == "Msg" { 73 | acknowledgements := msg[1].(map[string]interface{}) 74 | cmd := acknowledgements["cmd"] 75 | // log.Info(cmd) 76 | if cmd != "ack" { 77 | return 78 | } 79 | ack := acknowledgements["ack"].(float64) 80 | whatsappID := acknowledgements["id"] 81 | time := acknowledgements["t"].(float64) 82 | timeInt := uint64(time) 83 | from := acknowledgements["from"] 84 | to := acknowledgements["to"] 85 | // log.Info(ack) 86 | if ack == 2.0 { 87 | storage.UpdateMessageReceivedAt(whatsappID.(string), timeInt) 88 | 89 | go wh.NotifyReceive(from.(string),to.(string)) 90 | 91 | } else if ack == 3.0 { 92 | storage.UpdateMessageReadAt(whatsappID.(string), timeInt) 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /whatsapp/handle_new_contact.go: -------------------------------------------------------------------------------- 1 | package whatsapp 2 | 3 | import ( 4 | // "bytes" 5 | // "encoding/json" 6 | // "fmt" 7 | // "time" 8 | // "strings" 9 | // "bitbucket.org/rockyOO7/wa-api/gen/models" 10 | // "github.com/go-openapi/strfmt" 11 | wa "github.com/Rhymen/go-whatsapp" 12 | // log "github.com/sirupsen/logrus" 13 | ) 14 | 15 | // 16 | func (wh *WaHandler) HandleNewContact(contact wa.Contact) { 17 | 18 | 19 | // log.Infof("post Contact : %v", NumberFromWidJid(contact.Jid)) 20 | /* 21 | if wh.Hook == nil { 22 | log.Warnf("No hook specified for %v", wh.Wac.Info.Wid) 23 | return 24 | } 25 | 26 | sessionID := strfmt.UUID4(*wh.SessionID) 27 | number := NumberFromWidJid(wh.Wac.Info.Wid) 28 | percent := int64(message.Percentage) 29 | contactMessage := models.MessageBattery{ 30 | SessionID: &sessionID, 31 | Number: &number, 32 | Plugged: &message.Plugged, 33 | Powersave: &message.Powersave, 34 | Percentage: &percent, 35 | } 36 | 37 | messageBytes, err := json.Marshal(contactMessage) 38 | if err != nil { 39 | log.Errorf("Request Json Marshal failed with error %v", err) 40 | return 41 | } 42 | 43 | err = Retry(10, time.Millisecond*500, func() error { 44 | return requestWith(fmt.Sprintf("%v/power/battery", *wh.Hook), "application/json", bytes.NewReader(messageBytes)) 45 | }) 46 | 47 | if err != nil { 48 | log.Errorf("Contact Request Failed with error %v", err) 49 | } 50 | */ 51 | 52 | } 53 | -------------------------------------------------------------------------------- /whatsapp/message.go: -------------------------------------------------------------------------------- 1 | package whatsapp 2 | 3 | import ( 4 | wa "github.com/Rhymen/go-whatsapp" 5 | "github.com/Rhymen/go-whatsapp/binary/proto" 6 | log "github.com/sirupsen/logrus" 7 | ) 8 | 9 | // 10 | type MessageHandler struct { 11 | Wac *wa.Conn 12 | message *proto.WebMessageInfo 13 | } 14 | 15 | // 16 | func GetMessageForID(wac *wa.Conn, number, messageID string, fromMe bool) *proto.Message { 17 | log.Infof("GetMessageForID") 18 | handler := &MessageHandler{ 19 | Wac: wac, 20 | } 21 | jid := WidJidFromNumber(number) 22 | wac.LoadChatMessages(jid, 1, messageID, fromMe, false, handler) 23 | messageID = handler.message.GetKey().GetId() 24 | fromMe = handler.message.GetKey().GetFromMe() 25 | wac.LoadChatMessages(jid, 1, messageID, fromMe, true, handler) 26 | messageID = handler.message.GetKey().GetId() 27 | return handler.message.GetMessage() 28 | } 29 | 30 | // 31 | func (h *MessageHandler) ShouldCallSynchronously() bool { 32 | return true 33 | } 34 | 35 | // 36 | func (h *MessageHandler) HandleError(err error) { 37 | log.Infof("The Error occured while retrieving message: %v", err) 38 | } 39 | 40 | // 41 | func (h *MessageHandler) HandleRawMessage(m *proto.WebMessageInfo) { 42 | h.message = m 43 | } 44 | --------------------------------------------------------------------------------