k_sequencing 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/README.md +80 -0
- data/Rakefile +2 -0
- data/docs/documentation.md +254 -0
- data/k_sequencing.gemspec +23 -0
- data/lib/k_sequencing/client.rb +29 -0
- data/lib/k_sequencing/client_response.rb +23 -0
- data/lib/k_sequencing/connection.rb +65 -0
- data/lib/k_sequencing/error.rb +15 -0
- data/lib/k_sequencing/faraday/raise_http_exception.rb +46 -0
- data/lib/k_sequencing/version.rb +3 -0
- data/lib/k_sequencing.rb +11 -0
- metadata +132 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 93ef61a650856980af253bb1d454f311411fbaad
         | 
| 4 | 
            +
              data.tar.gz: a70ad95c23d79ce0be95b7fe1f59aa0074f1635c
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 206fcbb162c220285719976891445cd37e03b14f2e0b618983548e5043ad9393623df5f33d976a7c97931bee17249427532a04ade88353e6491321f01117d796
         | 
| 7 | 
            +
              data.tar.gz: 5d20e6a370f8c783aceac48dca626bde26622d887fc8e3a726bea4d544405b9025972753d948424f814969f2df6461b0107baee348010db44b0ffaa4ddd433fc
         | 
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            *.gem
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,80 @@ | |
| 1 | 
            +
            # k_sequencing_gem
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Image and content moderation services.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Getting Started
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            KSequencing 0.0.2 works with Rails 4.1 onwards. You can add it to your Gemfile with:
         | 
| 8 | 
            +
            ```ruby
         | 
| 9 | 
            +
            gem 'k_sequencing'
         | 
| 10 | 
            +
            ```
         | 
| 11 | 
            +
            Then run bundle install
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            You have to contact us [Kiyo](http://kiyo.tech/pages/contact) to get your token. With this token you'll be able to use our gem properly.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ## Usage
         | 
| 16 | 
            +
            ### Operations about Images
         | 
| 17 | 
            +
            Create images
         | 
| 18 | 
            +
            ```ruby
         | 
| 19 | 
            +
            KSequencing.client.create_image_closed_questions()
         | 
| 20 | 
            +
            ```
         | 
| 21 | 
            +
            | Field        | Type           | Required  | Description |
         | 
| 22 | 
            +
            | ------------- |:-------------:| :-----:| :-----|
         | 
| 23 | 
            +
            | token     | 	string | Yes |User Authorization Token|
         | 
| 24 | 
            +
            | data     | 	string | Yes |Data for moderate|
         | 
| 25 | 
            +
            | postback_url	     | string      |   Yes | Image postback url|
         | 
| 26 | 
            +
            | postback_method     | 	string | No |Postback method|
         | 
| 27 | 
            +
            | custom_id	     | string      |   No |Custom's id|
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            Sample request
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            ```ruby
         | 
| 32 | 
            +
            KSequencing.client.create_image_closed_questions(
         | 
| 33 | 
            +
              token: "9UPmGGWEwBsJrVnw6844tfpd",
         | 
| 34 | 
            +
              data: "image_url",
         | 
| 35 | 
            +
              postback_url: "www.example.com"
         | 
| 36 | 
            +
            )
         | 
| 37 | 
            +
            ```
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ```
         | 
| 40 | 
            +
            curl --request POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -H "Authorization: 9UPmGGWEwBsJrVnw6844tfpd" --data "data=image_url&postback_url=www.example.com" "http://k-sequencing.datawow.io/api/images/closed_questions"
         | 
| 41 | 
            +
            ```
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            Sample results
         | 
| 44 | 
            +
            ```json
         | 
| 45 | 
            +
            {
         | 
| 46 | 
            +
              "data": {
         | 
| 47 | 
            +
                "id": {
         | 
| 48 | 
            +
                  "$oid": "58c7a9f412c09f1c0fa78390"
         | 
| 49 | 
            +
                },
         | 
| 50 | 
            +
                "answer": null,
         | 
| 51 | 
            +
                "credit_charged": 0,
         | 
| 52 | 
            +
                "custom_id": null,
         | 
| 53 | 
            +
                "data": "image_url",
         | 
| 54 | 
            +
                "deadline_at": "2017-03-14T08:29:40.697+00:00",
         | 
| 55 | 
            +
                "postback_url": "www.example.com",
         | 
| 56 | 
            +
                "process": false,
         | 
| 57 | 
            +
                "processed_at": null,
         | 
| 58 | 
            +
                "project_id": null,
         | 
| 59 | 
            +
                "staff_id": null,
         | 
| 60 | 
            +
                "created_at": "2017-03-14T08:29:40.696Z",
         | 
| 61 | 
            +
                "updated_at": "2017-03-14T08:29:40.696Z"
         | 
| 62 | 
            +
              },
         | 
| 63 | 
            +
              "meta": {
         | 
| 64 | 
            +
                "code": 200,
         | 
| 65 | 
            +
                "message": "success"
         | 
| 66 | 
            +
              }
         | 
| 67 | 
            +
            }
         | 
| 68 | 
            +
            ```
         | 
| 69 | 
            +
            ---
         | 
| 70 | 
            +
            #### Image moderation can set 4 kinds of answer
         | 
| 71 | 
            +
            * Closed question - Answer can be only approved, declined or ban.
         | 
| 72 | 
            +
            * Choices - User can set multiple choices for select. It can be radio or checkbox.
         | 
| 73 | 
            +
            * Photo tag - User can create box-like overlays on top of your image and assign messages to each box.
         | 
| 74 | 
            +
            * Message - User can set messages for answer.
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            For more usage, please read [documentation](docs/documentation.md) for details on our code.
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            ## License
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            This project is licensed under datawowio
         | 
    
        data/Rakefile
    ADDED
    
    
| @@ -0,0 +1,254 @@ | |
| 1 | 
            +
            ## Usage
         | 
| 2 | 
            +
            ### Operations about Images
         | 
| 3 | 
            +
            #### Image moderation can set 4 kinds of answer
         | 
| 4 | 
            +
            * [Closed questions](#closed-questions)- Answer can be only approved, declined or ban.
         | 
| 5 | 
            +
            * [Choices](#choices) - User can set multiple choices for select. It can be radio or checkbox.
         | 
| 6 | 
            +
            * [Photo tags](#photo-tags) - User can create box-like overlays on top of your image and assign messages to each box.
         | 
| 7 | 
            +
            * [Messages](#messages) - User can set messages for answer.
         | 
| 8 | 
            +
            ---
         | 
| 9 | 
            +
            #### Closed questions
         | 
| 10 | 
            +
            Create images
         | 
| 11 | 
            +
            ```ruby
         | 
| 12 | 
            +
            KSequencing.client.create_image_closed_questions()
         | 
| 13 | 
            +
            ```
         | 
| 14 | 
            +
            | Field        | Type           | Required  | Description |
         | 
| 15 | 
            +
            | ------------- |:-------------:| :-----:| :-----|
         | 
| 16 | 
            +
            | token     | 	string | Yes |Project Authorization Token|
         | 
| 17 | 
            +
            | data     | 	string | Yes |Data for moderate|
         | 
| 18 | 
            +
            | postback_url	     | string      |   Yes | Image postback url|
         | 
| 19 | 
            +
            | postback_method     | 	string | No |Postback method|
         | 
| 20 | 
            +
            | custom_id	     | string      |   No |Custom's id|
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            Sample request
         | 
| 23 | 
            +
            ```ruby
         | 
| 24 | 
            +
            KSequencing.client.create_image_closed_questions(
         | 
| 25 | 
            +
              token: "9UPmGGWEwBsJrVnw6844tfpd",
         | 
| 26 | 
            +
              data: "image_url",
         | 
| 27 | 
            +
              postback_url: "www.example.com"
         | 
| 28 | 
            +
            )
         | 
| 29 | 
            +
            ```
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            ```
         | 
| 32 | 
            +
            curl --request POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -H "Authorization: 9UPmGGWEwBsJrVnw6844tfpd" --data "data=image_url&postback_url=www.example.com" "http://k-sequencing.datawow.io/api/images/closed_questions"
         | 
| 33 | 
            +
            ```
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            Sample results
         | 
| 36 | 
            +
            ```json
         | 
| 37 | 
            +
            {
         | 
| 38 | 
            +
              "data": {
         | 
| 39 | 
            +
                "id": {
         | 
| 40 | 
            +
                  "$oid": "58c7a9f412c09f1c0fa78390"
         | 
| 41 | 
            +
                },
         | 
| 42 | 
            +
                "answer": null,
         | 
| 43 | 
            +
                "credit_charged": 0,
         | 
| 44 | 
            +
                "custom_id": null,
         | 
| 45 | 
            +
                "data": "image_url",
         | 
| 46 | 
            +
                "deadline_at": "2017-03-14T08:29:40.697+00:00",
         | 
| 47 | 
            +
                "postback_url": "www.example.com",
         | 
| 48 | 
            +
                "process": false,
         | 
| 49 | 
            +
                "processed_at": null,
         | 
| 50 | 
            +
                "project_id": 1,
         | 
| 51 | 
            +
                "staff_id": null,
         | 
| 52 | 
            +
                "created_at": "2017-03-14T08:29:40.696Z",
         | 
| 53 | 
            +
                "updated_at": "2017-03-14T08:29:40.696Z"
         | 
| 54 | 
            +
              },
         | 
| 55 | 
            +
              "meta": {
         | 
| 56 | 
            +
                "code": 200,
         | 
| 57 | 
            +
                "message": "success"
         | 
| 58 | 
            +
              }
         | 
| 59 | 
            +
            }
         | 
| 60 | 
            +
            ```
         | 
| 61 | 
            +
            ---
         | 
| 62 | 
            +
            #### Choices
         | 
| 63 | 
            +
            Create new choices
         | 
| 64 | 
            +
            ```ruby
         | 
| 65 | 
            +
            KSequencing.client.create_choices()
         | 
| 66 | 
            +
            ```
         | 
| 67 | 
            +
            | Field        | Type           | Required  | Description |
         | 
| 68 | 
            +
            | ------------- |:-------------:| :-----:| :-----|
         | 
| 69 | 
            +
            | token     | 	string | Yes |Project Authorization Token|
         | 
| 70 | 
            +
            | instruction	     | string      |   Yes | Image instruction|
         | 
| 71 | 
            +
            |categories | Array[string]     |    Yes | Categories of answers |
         | 
| 72 | 
            +
            | data     | 	string | Yes |Data for attachment|
         | 
| 73 | 
            +
            | postback_url	     | string      |   Yes | Image instruction|
         | 
| 74 | 
            +
            |multiple | boolean   |    No | true for multiple answer and false for one answer |
         | 
| 75 | 
            +
            | postback_method     | 	string | No |Postback method|
         | 
| 76 | 
            +
            | custom_id	     | string      |   No |Custom's id|
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            Note: Answer can choose only one is default. If you want answer to be multiple, you need to set multiple to true.
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            Sample request
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            For one answer
         | 
| 83 | 
            +
            ```ruby
         | 
| 84 | 
            +
            KSequencing.client.create_choices(
         | 
| 85 | 
            +
              token: "9UPmGGWEwBsJrVnw6844tfpd",
         | 
| 86 | 
            +
              instruction: "question",
         | 
| 87 | 
            +
              categories: ["options1", "options2", "options3"],
         | 
| 88 | 
            +
              data: "image_url",
         | 
| 89 | 
            +
              postback_url: "www.example.com"
         | 
| 90 | 
            +
            )
         | 
| 91 | 
            +
            ```
         | 
| 92 | 
            +
            For multiple answer
         | 
| 93 | 
            +
            ```ruby
         | 
| 94 | 
            +
            KSequencing.client.create_choices(
         | 
| 95 | 
            +
              token: "9UPmGGWEwBsJrVnw6844tfpd",
         | 
| 96 | 
            +
              instruction: "question",
         | 
| 97 | 
            +
              categories: ["options1", "options2", "options3"],
         | 
| 98 | 
            +
              data: "image_url",
         | 
| 99 | 
            +
              postback_url: "www.example.com",
         | 
| 100 | 
            +
              multiple: true
         | 
| 101 | 
            +
            )
         | 
| 102 | 
            +
            ```
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            ```
         | 
| 105 | 
            +
            curl --request POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -H "Authorization: 9UPmGGWEwBsJrVnw6844tfpd" --data "instruction=question&categories=option1%20options2%20options3&data=image_url&postback_url=www.example.com" "http://k-sequencing.datawow.io/api/images/choices"
         | 
| 106 | 
            +
            ```
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            Sample results
         | 
| 109 | 
            +
            ```json
         | 
| 110 | 
            +
            {
         | 
| 111 | 
            +
              "data": {
         | 
| 112 | 
            +
                "id": {
         | 
| 113 | 
            +
                  "$oid": "58c8c39012c09f1c0fa78391"
         | 
| 114 | 
            +
                },
         | 
| 115 | 
            +
                "answer": null,
         | 
| 116 | 
            +
                "credit_charged": 0,
         | 
| 117 | 
            +
                "custom_id": null,
         | 
| 118 | 
            +
                "data": "image_url",
         | 
| 119 | 
            +
                "deadline_at": "2017-03-15T04:31:12.601+00:00",
         | 
| 120 | 
            +
                "postback_url": "www.example.com",
         | 
| 121 | 
            +
                "process": false,
         | 
| 122 | 
            +
                "instruction": "question",
         | 
| 123 | 
            +
                "categories": [
         | 
| 124 | 
            +
                  "option1",
         | 
| 125 | 
            +
                  "option2",
         | 
| 126 | 
            +
                  "option3"
         | 
| 127 | 
            +
                ],
         | 
| 128 | 
            +
                "project_id": 1,
         | 
| 129 | 
            +
                "multiple": false,
         | 
| 130 | 
            +
                "processed_at": null,
         | 
| 131 | 
            +
                "staff_id": null,
         | 
| 132 | 
            +
                "created_at": "2017-03-15T04:31:12.600Z",
         | 
| 133 | 
            +
                "updated_at": "2017-03-15T04:31:12.600Z"
         | 
| 134 | 
            +
              },
         | 
| 135 | 
            +
              "meta": {
         | 
| 136 | 
            +
                "code": 200,
         | 
| 137 | 
            +
                "message": "success"
         | 
| 138 | 
            +
              }
         | 
| 139 | 
            +
            }
         | 
| 140 | 
            +
             | 
| 141 | 
            +
            ```
         | 
| 142 | 
            +
            ---
         | 
| 143 | 
            +
            #### Messages
         | 
| 144 | 
            +
            Create new message
         | 
| 145 | 
            +
            ```ruby
         | 
| 146 | 
            +
            KSequencing.client.create_messages()
         | 
| 147 | 
            +
            ```
         | 
| 148 | 
            +
            | Field        | Type           | Required  | Description |
         | 
| 149 | 
            +
            | ------------- |:-------------:| :-----:| :-----|
         | 
| 150 | 
            +
            | token     | 	string | Yes |Project Authorization Token|
         | 
| 151 | 
            +
            | instruction	     | string      |   Yes | Image instruction|
         | 
| 152 | 
            +
            | data     | 	string | Yes |Data for attachment|
         | 
| 153 | 
            +
            | postback_url	     | string      |   Yes | Image postback url|
         | 
| 154 | 
            +
            | postback_method     | 	string | No |Postback method|
         | 
| 155 | 
            +
            | custom_id	     | string      |   No |Custom's id|
         | 
| 156 | 
            +
             | 
| 157 | 
            +
            Sample request
         | 
| 158 | 
            +
            ```ruby
         | 
| 159 | 
            +
            KSequencing.client.create_messages(
         | 
| 160 | 
            +
              token: "9UPmGGWEwBsJrVnw6844tfpd",
         | 
| 161 | 
            +
              instruction: "question",
         | 
| 162 | 
            +
              data: "image_url",
         | 
| 163 | 
            +
              postback_url: "www.example.com"
         | 
| 164 | 
            +
            )
         | 
| 165 | 
            +
            ```
         | 
| 166 | 
            +
             | 
| 167 | 
            +
            ```
         | 
| 168 | 
            +
            curl --request POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -H "Authorization: 9UPmGGWEwBsJrVnw6844tfpd" --data "instruction=question&data=image_url&postback_url=www.example.com" "http://k-sequencing.datawow.io/api/images/messages"
         | 
| 169 | 
            +
            ```
         | 
| 170 | 
            +
             | 
| 171 | 
            +
            Sample results
         | 
| 172 | 
            +
            ```json
         | 
| 173 | 
            +
            {
         | 
| 174 | 
            +
              "data": {
         | 
| 175 | 
            +
                "id": {
         | 
| 176 | 
            +
                  "$oid": "58c8c3ef12c09f1c0fa78392"
         | 
| 177 | 
            +
                },
         | 
| 178 | 
            +
                "answer": null,
         | 
| 179 | 
            +
                "credit_charged": 0,
         | 
| 180 | 
            +
                "custom_id": null,
         | 
| 181 | 
            +
                "data": "image_url",
         | 
| 182 | 
            +
                "deadline_at": "2017-03-15T04:32:47.763+00:00",
         | 
| 183 | 
            +
                "postback_url": "www.example.com",
         | 
| 184 | 
            +
                "process": false,
         | 
| 185 | 
            +
                "instruction": "question",
         | 
| 186 | 
            +
                "project_id": 1,
         | 
| 187 | 
            +
                "processed_at": null,
         | 
| 188 | 
            +
                "staff_id": null,
         | 
| 189 | 
            +
                "created_at": "2017-03-15T04:32:47.762Z",
         | 
| 190 | 
            +
                "updated_at": "2017-03-15T04:32:47.762Z"
         | 
| 191 | 
            +
              },
         | 
| 192 | 
            +
              "meta": {
         | 
| 193 | 
            +
                "code": 200,
         | 
| 194 | 
            +
                "message": "success"
         | 
| 195 | 
            +
              }
         | 
| 196 | 
            +
            }
         | 
| 197 | 
            +
            ```
         | 
| 198 | 
            +
            ---
         | 
| 199 | 
            +
            #### Photo tags
         | 
| 200 | 
            +
            Create new photo tag
         | 
| 201 | 
            +
            ```ruby
         | 
| 202 | 
            +
            KSequencing.client.create_photo_tags()
         | 
| 203 | 
            +
            ```
         | 
| 204 | 
            +
            | Field        | Type           | Required  | Description |
         | 
| 205 | 
            +
            | ------------- |:-------------:| :-----:| :-----|
         | 
| 206 | 
            +
            | token     | 	string | Yes |Project Authorization Token|
         | 
| 207 | 
            +
            | instruction	     | string      |   Yes | Image instruction|
         | 
| 208 | 
            +
            | data     | 	string | Yes |Data for attachment|
         | 
| 209 | 
            +
            | postback_url	     | string      |   Yes | Image postback url|
         | 
| 210 | 
            +
            | postback_method     | 	string | No |Postback method|
         | 
| 211 | 
            +
            | custom_id	     | string      |   No |Custom's id|
         | 
| 212 | 
            +
             | 
| 213 | 
            +
            Sample request
         | 
| 214 | 
            +
            ```ruby
         | 
| 215 | 
            +
            KSequencing.client.create_photo_tags(
         | 
| 216 | 
            +
              token: "9UPmGGWEwBsJrVnw6844tfpd",
         | 
| 217 | 
            +
              instruction: "question",
         | 
| 218 | 
            +
              data: "image_url",
         | 
| 219 | 
            +
              postback_url: "www.example.com"
         | 
| 220 | 
            +
            )
         | 
| 221 | 
            +
            ```
         | 
| 222 | 
            +
             | 
| 223 | 
            +
            ```
         | 
| 224 | 
            +
            curl --request POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" --H "Authorization: 9UPmGGWEwBsJrVnw6844tfpd" --data "instruction=question&data=image_url&postback_url=www.example.com" "http://k-sequencing.datawow.io/api/images/photo_tags"
         | 
| 225 | 
            +
            ```
         | 
| 226 | 
            +
             | 
| 227 | 
            +
            Sample results
         | 
| 228 | 
            +
            ```json
         | 
| 229 | 
            +
            {
         | 
| 230 | 
            +
              "data": {
         | 
| 231 | 
            +
                "id": {
         | 
| 232 | 
            +
                  "$oid": "58c8c45c12c09f1c0fa78394"
         | 
| 233 | 
            +
                },
         | 
| 234 | 
            +
                "answer": null,
         | 
| 235 | 
            +
                "credit_charged": 0,
         | 
| 236 | 
            +
                "custom_id": null,
         | 
| 237 | 
            +
                "data": "image_url",
         | 
| 238 | 
            +
                "deadline_at": "2017-03-15T04:34:36.231+00:00",
         | 
| 239 | 
            +
                "postback_url": "www.example.com",
         | 
| 240 | 
            +
                "process": false,
         | 
| 241 | 
            +
                "instruction": "question",
         | 
| 242 | 
            +
                "project_id": 1,
         | 
| 243 | 
            +
                "processed_at": null,
         | 
| 244 | 
            +
                "staff_id": null,
         | 
| 245 | 
            +
                "created_at": "2017-03-15T04:34:36.230Z",
         | 
| 246 | 
            +
                "updated_at": "2017-03-15T04:34:36.230Z"
         | 
| 247 | 
            +
              },
         | 
| 248 | 
            +
              "meta": {
         | 
| 249 | 
            +
                "code": 200,
         | 
| 250 | 
            +
                "message": "success"
         | 
| 251 | 
            +
              }
         | 
| 252 | 
            +
            }
         | 
| 253 | 
            +
            ```
         | 
| 254 | 
            +
            ---
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name          = 'k_sequencing'
         | 
| 7 | 
            +
              s.version       = '0.0.2'
         | 
| 8 | 
            +
              s.date          = '2017-05-24'
         | 
| 9 | 
            +
              s.summary       = 'KSequencing is a moderator service for your online content'
         | 
| 10 | 
            +
              s.description   = 'Moderation suite'
         | 
| 11 | 
            +
              s.authors       = ['Jesdakorn Samittiauttakorn']
         | 
| 12 | 
            +
              s.email         = 'ton@nanameue.jp'
         | 
| 13 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 14 | 
            +
              s.homepage      = 'https://kiyo.tech'
         | 
| 15 | 
            +
              s.license       = 'Commercial'
         | 
| 16 | 
            +
              s.require_paths = ['lib']
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
         | 
| 19 | 
            +
              s.add_runtime_dependency 'activesupport', '4.1'
         | 
| 20 | 
            +
              s.add_runtime_dependency 'faraday', '~> 0.9.2'
         | 
| 21 | 
            +
              s.add_runtime_dependency 'faraday_middleware', '~> 0.10.0'
         | 
| 22 | 
            +
              s.add_runtime_dependency 'faraday_middleware-active_support_json', '~> 0.0.3'
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            module KSequencing
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Client
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def create_choices(options = {})
         | 
| 6 | 
            +
                  connection.post("/api/images/choices", options)
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def create_image_closed_questions(options = {})
         | 
| 10 | 
            +
                  connection.post("/api/images/closed_questions", options)
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def create_messages(options = {})
         | 
| 14 | 
            +
                  connection.post("/api/images/messages", options)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def create_photo_tags(options = {})
         | 
| 18 | 
            +
                  connection.post("/api/images/photo_tags", options)
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                private
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def connection
         | 
| 24 | 
            +
                  @connection ||= Connection.new
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            module KSequencing
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Response
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                attr_reader :count, :message, :status
         | 
| 6 | 
            +
                attr_accessor :value, :meta
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                def initialize(value, success, response_code = "", response_message = "success", meta = nil, total = 0)
         | 
| 9 | 
            +
                  @value = value
         | 
| 10 | 
            +
                  @success = success
         | 
| 11 | 
            +
                  @status = response_code
         | 
| 12 | 
            +
                  @message = response_message
         | 
| 13 | 
            +
                  @total = total
         | 
| 14 | 
            +
                  @meta = meta
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def successful?
         | 
| 18 | 
            +
                  !something.nil?
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,65 @@ | |
| 1 | 
            +
            require File.expand_path("../faraday/raise_http_exception.rb", __FILE__)
         | 
| 2 | 
            +
            require File.expand_path("../client_response.rb", __FILE__)
         | 
| 3 | 
            +
            require 'active_support/all'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module KSequencing
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              class Connection
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def post(path, options = {}, query_params = {})
         | 
| 10 | 
            +
                  response = connection.post do |request|
         | 
| 11 | 
            +
                    request.path = path
         | 
| 12 | 
            +
                    request.headers["Content-Type"] = "application/json"
         | 
| 13 | 
            +
                    request.headers["Authorization"] = options[:token] unless options[:token].nil?
         | 
| 14 | 
            +
                    request.params = query_params
         | 
| 15 | 
            +
                    request.body = options unless options.empty?
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                  Response.new(data(response), true, response.status)
         | 
| 18 | 
            +
                rescue Error, Faraday::Error => e
         | 
| 19 | 
            +
                  handle_error(e)
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                private
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def connection
         | 
| 25 | 
            +
                  options = {
         | 
| 26 | 
            +
                    url: 'http://localhost:3001'
         | 
| 27 | 
            +
                  }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  @connection ||= Faraday::Connection.new(options) do |connection|
         | 
| 30 | 
            +
                    connection.request :url_encoded
         | 
| 31 | 
            +
                    connection.request :json
         | 
| 32 | 
            +
                    connection.response :json
         | 
| 33 | 
            +
                    connection.use KSequencing::FaradayMiddleware::RaiseHttpException
         | 
| 34 | 
            +
                    connection.use :gzip
         | 
| 35 | 
            +
                    connection.adapter Faraday.default_adapter
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def meta(response)
         | 
| 40 | 
            +
                  response.body["meta"]
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def total(response)
         | 
| 44 | 
            +
                  meta(response)["count"] if meta(response).present?
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                def data(response)
         | 
| 48 | 
            +
                  response.body["data"]
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def handle_error(exception)
         | 
| 52 | 
            +
                  if exception.is_a?(Faraday::ConnectionFailed)
         | 
| 53 | 
            +
                    code = 599
         | 
| 54 | 
            +
                    message = "Connection Failed"
         | 
| 55 | 
            +
                  else
         | 
| 56 | 
            +
                    code = exception.to_s.partition(":").first
         | 
| 57 | 
            +
                    message = exception.to_s.partition(":").last
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  Response.new(nil, false, code, message, 0)
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            module KSequencing
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              # Custom error class for rescuing from all API errors
         | 
| 4 | 
            +
              class Error < StandardError; end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              # Raised when API returns the HTTP status code 400
         | 
| 7 | 
            +
              class BadRequest < Error; end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              # Raised when API returns the HTTP status code 403
         | 
| 10 | 
            +
              class NotPermitted < Error; end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              # Raised when API returns the HTTP status code 404
         | 
| 13 | 
            +
              class NotFound < Error; end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            require 'faraday_middleware'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module KSequencing
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              module FaradayMiddleware
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                class RaiseHttpException < Faraday::Middleware
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def call(request_env)
         | 
| 10 | 
            +
                    @app.call(request_env).on_complete do |response|
         | 
| 11 | 
            +
                      case response[:status].to_i
         | 
| 12 | 
            +
                      when 200, 201
         | 
| 13 | 
            +
                        # nothing to do here
         | 
| 14 | 
            +
                      when 400
         | 
| 15 | 
            +
                        error_message = error_message(response[:body])
         | 
| 16 | 
            +
                        raise BadRequest, "#{response[:status]}: #{error_message}"
         | 
| 17 | 
            +
                      when 403
         | 
| 18 | 
            +
                        error_message = error_message(response[:body])
         | 
| 19 | 
            +
                        raise NotPermitted, "#{response[:status]}: #{error_message}"
         | 
| 20 | 
            +
                      when 404
         | 
| 21 | 
            +
                        error_message = error_message(response[:body])
         | 
| 22 | 
            +
                        raise NotFound, "#{response[:status]}: #{error_message}"
         | 
| 23 | 
            +
                      else
         | 
| 24 | 
            +
                        request_method = response[:method].to_s.upcase
         | 
| 25 | 
            +
                        request_url = response[:url].to_s
         | 
| 26 | 
            +
                        response_status = response[:status]
         | 
| 27 | 
            +
                        error_message = error_message(response[:body])
         | 
| 28 | 
            +
                        raise Error, "#{response_status}: #{request_method} #{request_url} #{error_message}"
         | 
| 29 | 
            +
                      end
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  private
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def error_message(response_body)
         | 
| 36 | 
            +
                    if response_body.present? && response_body.is_a?(String)
         | 
| 37 | 
            +
                      response_body = JSON.parse(response_body)
         | 
| 38 | 
            +
                      response_body["message"]
         | 
| 39 | 
            +
                    end
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            end
         | 
    
        data/lib/k_sequencing.rb
    ADDED
    
    | @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            require_relative 'k_sequencing/client'
         | 
| 2 | 
            +
            require_relative 'k_sequencing/client_response'
         | 
| 3 | 
            +
            require_relative 'k_sequencing/connection'
         | 
| 4 | 
            +
            require_relative 'k_sequencing/error'
         | 
| 5 | 
            +
            require_relative 'k_sequencing/version'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module KSequencing
         | 
| 8 | 
            +
              def self.client
         | 
| 9 | 
            +
                Client.new
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,132 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: k_sequencing
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Jesdakorn Samittiauttakorn
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2017-05-24 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: json
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.8'
         | 
| 20 | 
            +
                - - ">="
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 1.8.3
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - "~>"
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '1.8'
         | 
| 30 | 
            +
                - - ">="
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 1.8.3
         | 
| 33 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            +
              name: activesupport
         | 
| 35 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            +
                requirements:
         | 
| 37 | 
            +
                - - '='
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            +
                    version: '4.1'
         | 
| 40 | 
            +
              type: :runtime
         | 
| 41 | 
            +
              prerelease: false
         | 
| 42 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 | 
            +
                requirements:
         | 
| 44 | 
            +
                - - '='
         | 
| 45 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                    version: '4.1'
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              name: faraday
         | 
| 49 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - "~>"
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: 0.9.2
         | 
| 54 | 
            +
              type: :runtime
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                requirements:
         | 
| 58 | 
            +
                - - "~>"
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: 0.9.2
         | 
| 61 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 62 | 
            +
              name: faraday_middleware
         | 
| 63 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 64 | 
            +
                requirements:
         | 
| 65 | 
            +
                - - "~>"
         | 
| 66 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            +
                    version: 0.10.0
         | 
| 68 | 
            +
              type: :runtime
         | 
| 69 | 
            +
              prerelease: false
         | 
| 70 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 71 | 
            +
                requirements:
         | 
| 72 | 
            +
                - - "~>"
         | 
| 73 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 74 | 
            +
                    version: 0.10.0
         | 
| 75 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 76 | 
            +
              name: faraday_middleware-active_support_json
         | 
| 77 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 78 | 
            +
                requirements:
         | 
| 79 | 
            +
                - - "~>"
         | 
| 80 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 81 | 
            +
                    version: 0.0.3
         | 
| 82 | 
            +
              type: :runtime
         | 
| 83 | 
            +
              prerelease: false
         | 
| 84 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 85 | 
            +
                requirements:
         | 
| 86 | 
            +
                - - "~>"
         | 
| 87 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 88 | 
            +
                    version: 0.0.3
         | 
| 89 | 
            +
            description: Moderation suite
         | 
| 90 | 
            +
            email: ton@nanameue.jp
         | 
| 91 | 
            +
            executables: []
         | 
| 92 | 
            +
            extensions: []
         | 
| 93 | 
            +
            extra_rdoc_files: []
         | 
| 94 | 
            +
            files:
         | 
| 95 | 
            +
            - ".gitignore"
         | 
| 96 | 
            +
            - Gemfile
         | 
| 97 | 
            +
            - README.md
         | 
| 98 | 
            +
            - Rakefile
         | 
| 99 | 
            +
            - docs/documentation.md
         | 
| 100 | 
            +
            - k_sequencing.gemspec
         | 
| 101 | 
            +
            - lib/k_sequencing.rb
         | 
| 102 | 
            +
            - lib/k_sequencing/client.rb
         | 
| 103 | 
            +
            - lib/k_sequencing/client_response.rb
         | 
| 104 | 
            +
            - lib/k_sequencing/connection.rb
         | 
| 105 | 
            +
            - lib/k_sequencing/error.rb
         | 
| 106 | 
            +
            - lib/k_sequencing/faraday/raise_http_exception.rb
         | 
| 107 | 
            +
            - lib/k_sequencing/version.rb
         | 
| 108 | 
            +
            homepage: https://kiyo.tech
         | 
| 109 | 
            +
            licenses:
         | 
| 110 | 
            +
            - Commercial
         | 
| 111 | 
            +
            metadata: {}
         | 
| 112 | 
            +
            post_install_message: 
         | 
| 113 | 
            +
            rdoc_options: []
         | 
| 114 | 
            +
            require_paths:
         | 
| 115 | 
            +
            - lib
         | 
| 116 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 117 | 
            +
              requirements:
         | 
| 118 | 
            +
              - - ">="
         | 
| 119 | 
            +
                - !ruby/object:Gem::Version
         | 
| 120 | 
            +
                  version: '0'
         | 
| 121 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 122 | 
            +
              requirements:
         | 
| 123 | 
            +
              - - ">="
         | 
| 124 | 
            +
                - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                  version: '0'
         | 
| 126 | 
            +
            requirements: []
         | 
| 127 | 
            +
            rubyforge_project: 
         | 
| 128 | 
            +
            rubygems_version: 2.5.1
         | 
| 129 | 
            +
            signing_key: 
         | 
| 130 | 
            +
            specification_version: 4
         | 
| 131 | 
            +
            summary: KSequencing is a moderator service for your online content
         | 
| 132 | 
            +
            test_files: []
         |