Code Duplication    Length = 53-56 lines in 2 locations

includes/api/class-wc-rest-product-attributes-controller.php 1 location

@@ 518-570 (lines=53) @@
515
	 *
516
	 * @return array
517
	 */
518
	public function get_item_schema() {
519
		$schema = array(
520
			'$schema'              => 'http://json-schema.org/draft-04/schema#',
521
			'title'                => 'product_attribute',
522
			'type'                 => 'object',
523
			'properties'           => array(
524
				'id' => array(
525
					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
526
					'type'        => 'integer',
527
					'context'     => array( 'view', 'edit' ),
528
					'readonly'    => true,
529
				),
530
				'name' => array(
531
					'description' => __( 'Attribute name.', 'woocommerce' ),
532
					'type'        => 'string',
533
					'context'     => array( 'view', 'edit' ),
534
					'arg_options' => array(
535
						'sanitize_callback' => 'sanitize_text_field',
536
					),
537
				),
538
				'slug' => array(
539
					'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'woocommerce' ),
540
					'type'        => 'string',
541
					'context'     => array( 'view', 'edit' ),
542
					'arg_options' => array(
543
						'sanitize_callback' => 'sanitize_title',
544
					),
545
				),
546
				'type' => array(
547
					'description' => __( 'Type of attribute.', 'woocommerce' ),
548
					'type'        => 'string',
549
					'default'     => 'select',
550
					'enum'        => array_keys( wc_get_attribute_types() ),
551
					'context'     => array( 'view', 'edit' ),
552
				),
553
				'order_by' => array(
554
					'description' => __( 'Default sort order.', 'woocommerce' ),
555
					'type'        => 'string',
556
					'default'     => 'menu_order',
557
					'enum'        => array( 'menu_order', 'name', 'name_num', 'id' ),
558
					'context'     => array( 'view', 'edit' ),
559
				),
560
				'has_archives' => array(
561
					'description' => __( 'Enable/Disable attribute archives.', 'woocommerce' ),
562
					'type'        => 'boolean',
563
					'default'     => false,
564
					'context'     => array( 'view', 'edit' ),
565
				),
566
			),
567
		);
568
569
		return $this->add_additional_fields_schema( $schema );
570
	}
571
572
	/**
573
	 * Get the query params for collections

includes/api/class-wc-rest-shipping-zone-methods-controller.php 1 location

@@ 404-459 (lines=56) @@
401
	 *
402
	 * @return array
403
	 */
404
	public function get_item_schema() {
405
		$schema = array(
406
			'$schema'    => 'http://json-schema.org/draft-04/schema#',
407
			'title'      => 'shipping_zone_method',
408
			'type'       => 'object',
409
			'properties' => array(
410
				'instance_id' => array(
411
					'description' => __( 'Shipping method instance ID.', 'woocommerce' ),
412
					'type'        => 'integer',
413
					'context'     => array( 'view' ),
414
				),
415
				'title' => array(
416
					'description' => __( 'Shipping method customer facing title.', 'woocommerce' ),
417
					'type'        => 'string',
418
					'context'     => array( 'view' ),
419
				),
420
				'order' => array(
421
					'description' => __( 'Shipping method sort order.', 'woocommerce' ),
422
					'type'        => 'integer',
423
					'context'     => array( 'view', 'edit' ),
424
					'required'    => false,
425
					'arg_options' => array(
426
						'sanitize_callback' => 'absint',
427
					),
428
				),
429
				'enabled' => array(
430
					'description' => __( 'Shipping method enabled status.', 'woocommerce' ),
431
					'type'        => 'boolean',
432
					'context'     => array( 'view', 'edit' ),
433
					'required'    => false,
434
				),
435
				'method_id' => array(
436
					'description' => __( 'Shipping method ID. Write on create only.', 'woocommerce' ),
437
					'type'        => 'string',
438
					'context'     => array( 'view', 'edit.' ),
439
				),
440
				'method_title' => array(
441
					'description' => __( 'Shipping method title.', 'woocommerce' ),
442
					'type'        => 'string',
443
					'context'     => array( 'view' ),
444
				),
445
				'method_description' => array(
446
					'description' => __( 'Shipping method description.', 'woocommerce' ),
447
					'type'        => 'string',
448
					'context'     => array( 'view' ),
449
				),
450
				'settings' => array(
451
					'description' => __( 'Shipping method settings.', 'woocommerce' ),
452
					'type'        => 'array',
453
					'context'     => array( 'view', 'edit' ),
454
				),
455
			),
456
		);
457
458
		return $this->add_additional_fields_schema( $schema );
459
	}
460
}
461